cf/mirror

Message Spread

CF
2029H3500· legendary gm12s1024 MB⌨ stdin/stdout

Examples

Sample 1of 5
Input
2 1
1 2 1 10
Output
10
Sample 2of 5
Input
3 3
1 2 1 2
1 3 1 2
2 3 1 2
Output
887328316
Sample 3of 5
Input
1 0
Output
0
Sample 4of 5
Input
5 8
1 2 1 11
1 3 2 11
1 4 3 11
1 5 4 11
2 4 5 11
2 5 6 11
3 4 7 11
4 5 8 11
Output
469993557
Sample 5of 5
Input
21 22
1 2 3 4
2 3 4 5
3 4 5 6
5 6 7 8
6 7 8 9
7 8 9 10
8 9 2 3
9 10 3 4
10 11 4 5
11 12 5 6
12 13 6 7
13 14 7 8
14 15 8 9
15 16 9 10
16 17 2 3
17 18 3 4
18 19 4 5
19 20 5 6
20 21 6 7
1 10 100 1001
15 4 147 220
4 11 1 998244352
Output
299529765
2029H.cpp
loading editor…
Ln 11·137 BGNU C++20 (64)