QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#19524#2467. AutobusQingyu70 ✓127ms5412kbC++20918b2022-02-03 09:20:582022-05-06 05:41:10

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-06 05:41:10]
  • 评测
  • 测评结果:70
  • 用时:127ms
  • 内存:5412kb
  • [2022-02-03 09:20:58]
  • 提交

answer

#include <bits/stdc++.h>
const int N = 75;
int G[N][N], dp[N][N][N];
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	int n, m;
	memset(G, 0x3f, sizeof G);
	memset(dp, 0x3f, sizeof dp);
	std::cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		int x, y, w;
		std::cin >> x >> y >> w;
		G[x][y] = std::min(G[x][y], w);
	}
	for (int i = 1; i <= n; ++i) dp[0][i][i] = 0;
	for (int i = 1; i <= n; ++i) {
		for (int x = 1; x <= n; ++x)
			for (int y = 1; y <= n; ++y) {
				dp[i][x][y] = dp[i - 1][x][y];
				for (int z = 1; z <= n; ++z)
					dp[i][x][y] = std::min(dp[i][x][y], dp[i - 1][x][z] + G[z][y]);
			}
	}
	int k, q;
	std::cin >> k >> q;
	k = std::min(k, n);
	while (q--) {
		int x, y;
		std::cin >> x >> y;
		if (dp[k][x][y] >= 0x3f3f3f3f) {
			std::cout << -1 << '\n';
		}
		else {
			std::cout << dp[k][x][y] << '\n';
		}
	}
}

詳細信息

Subtask #1:

score: 15
Accepted

Test #1:

score: 15
Accepted
time: 4ms
memory: 5308kb

input:

7 20
4 3 878971
6 4 989156
5 1 271445
6 3 872596
6 6 689315
4 7 861935
4 2 392762
7 1 488107
1 1 196255
4 1 38239
5 2 777795
1 5 169627
7 7 910360
3 1 407642
7 3 877306
4 4 847613
4 4 275060
7 3 940526
1 2 362487
7 7 652976
2 49
1 1
2 1
3 1
4 1
5 1
6 1
7 1
1 2
2 2
3 2
4 2
5 2
6 2
7 2
1 3
2 3
3 3
4 3...

output:

0
-1
407642
38239
271445
1027395
488107
362487
0
770129
392762
633932
1381918
850594
-1
-1
0
878971
-1
872596
877306
-1
-1
-1
0
-1
989156
-1
169627
-1
577269
207866
0
-1
657734
-1
-1
-1
-1
-1
0
-1
-1
-1
-1
861935
-1
1851091
0

result:

ok 49 lines

Test #2:

score: 0
Accepted
time: 4ms
memory: 5320kb

input:

7 20
4 3 878971
6 4 989156
5 1 271445
6 3 872596
6 6 689315
4 7 861935
4 2 392762
7 1 488107
1 1 196255
4 1 38239
5 2 777795
1 5 169627
7 7 910360
3 1 407642
7 3 877306
4 4 847613
4 4 275060
7 3 940526
1 2 362487
7 7 652976
4 49
1 1
2 1
3 1
4 1
5 1
6 1
7 1
1 2
2 2
3 2
4 2
5 2
6 2
7 2
1 3
2 3
3 3
4 3...

output:

0
-1
407642
38239
271445
1027395
488107
362487
0
770129
392762
633932
1381918
850594
-1
-1
0
878971
-1
872596
877306
-1
-1
-1
0
-1
989156
-1
169627
-1
577269
207866
0
1197022
657734
-1
-1
-1
-1
-1
0
-1
-1
-1
-1
861935
-1
1851091
0

result:

ok 49 lines

Test #3:

score: 0
Accepted
time: 2ms
memory: 5248kb

input:

7 20
4 3 878971
6 4 989156
5 1 271445
6 3 872596
6 6 689315
4 7 861935
4 2 392762
7 1 488107
1 1 196255
4 1 38239
5 2 777795
1 5 169627
7 7 910360
3 1 407642
7 3 877306
4 4 847613
4 4 275060
7 3 940526
1 2 362487
7 7 652976
7 49
1 1
2 1
3 1
4 1
5 1
6 1
7 1
1 2
2 2
3 2
4 2
5 2
6 2
7 2
1 3
2 3
3 3
4 3...

output:

0
-1
407642
38239
271445
1027395
488107
362487
0
770129
392762
633932
1381918
850594
-1
-1
0
878971
-1
872596
877306
-1
-1
-1
0
-1
989156
-1
169627
-1
577269
207866
0
1197022
657734
-1
-1
-1
-1
-1
0
-1
-1
-1
-1
861935
-1
1851091
0

result:

ok 49 lines

Test #4:

score: 0
Accepted
time: 2ms
memory: 5224kb

input:

7 30
5 1 115814
1 1 96392
3 3 431819
6 1 468951
2 1 988240
3 1 90697
2 2 370264
7 6 678396
6 1 729039
3 7 256153
5 4 869649
4 6 964203
2 2 662141
7 1 655710
5 4 716753
7 7 238531
4 5 458734
6 2 749791
7 4 740392
1 4 51716
6 7 893144
4 3 585026
1 6 445351
3 3 57396
1 4 144568
3 6 875570
3 4 453914
4 ...

output:

0
881915
90697
-1
115814
468951
655710
-1
0
-1
-1
-1
749791
-1
-1
-1
0
223189
-1
-1
-1
51716
-1
453914
0
716753
-1
740392
-1
-1
-1
458734
0
-1
-1
445351
-1
875570
964203
-1
0
678396
-1
-1
256153
920980
-1
893144
0

result:

ok 49 lines

Test #5:

score: 0
Accepted
time: 0ms
memory: 5284kb

input:

7 30
5 1 115814
1 1 96392
3 3 431819
6 1 468951
2 1 988240
3 1 90697
2 2 370264
7 6 678396
6 1 729039
3 7 256153
5 4 869649
4 6 964203
2 2 662141
7 1 655710
5 4 716753
7 7 238531
4 5 458734
6 2 749791
7 4 740392
1 4 51716
6 7 893144
4 3 585026
1 6 445351
3 3 57396
1 4 144568
3 6 875570
3 4 453914
4 ...

output:

0
881915
90697
313886
115814
468951
655710
1195142
0
1285839
1713994
1310956
749791
1428187
274905
1156820
0
223189
390719
743856
930615
51716
933631
142413
0
167530
520667
707426
510450
1392365
601147
458734
0
979401
1166160
445351
1327266
536048
759237
561165
0
678396
531058
1854611
256153
479342
...

result:

ok 49 lines

Test #6:

score: 0
Accepted
time: 2ms
memory: 5276kb

input:

7 30
5 1 115814
1 1 96392
3 3 431819
6 1 468951
2 1 988240
3 1 90697
2 2 370264
7 6 678396
6 1 729039
3 7 256153
5 4 869649
4 6 964203
2 2 662141
7 1 655710
5 4 716753
7 7 238531
4 5 458734
6 2 749791
7 4 740392
1 4 51716
6 7 893144
4 3 585026
1 6 445351
3 3 57396
1 4 144568
3 6 875570
3 4 453914
4 ...

output:

0
881915
90697
313886
115814
468951
655710
1195142
0
1285839
1509028
1310956
749791
1428187
274905
1156820
0
223189
390719
743856
930615
51716
933631
142413
0
167530
520667
707426
510450
1392365
601147
458734
0
979401
1166160
445351
1327266
536048
759237
561165
0
678396
531058
1412973
256153
479342
...

result:

ok 49 lines

Subtask #2:

score: 15
Accepted

Test #7:

score: 15
Accepted
time: 16ms
memory: 5280kb

input:

70 490
50 30 591339
38 8 564617
11 63 805095
61 29 69176
19 35 453990
28 50 672168
26 57 541776
63 15 307625
65 15 747996
5 17 414836
43 18 776234
29 69 734517
39 51 959948
45 62 933398
9 9 132078
20 23 921720
41 68 749130
38 6 378417
54 23 563031
2 49 665025
45 42 901865
33 18 636978
4 57 982955
25...

output:

0
-1
-1
-1
-1
-1
-1
83200
-1
-1
-1
-1
-1
-1
585015
-1
143830
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
116243
-1
-1
265692
-1
-1
-1
-1
-1
-1
-1
-1
-1
0
-1
-1
-1
577739
-1
-1
-1
-1
908449
-1
-1
-1
-1
-1
-1
-1
120247
-1
-...

result:

ok 4900 lines

Test #8:

score: 0
Accepted
time: 19ms
memory: 5412kb

input:

70 490
50 30 591339
38 8 564617
11 63 805095
61 29 69176
19 35 453990
28 50 672168
26 57 541776
63 15 307625
65 15 747996
5 17 414836
43 18 776234
29 69 734517
39 51 959948
45 62 933398
9 9 132078
20 23 921720
41 68 749130
38 6 378417
54 23 563031
2 49 665025
45 42 901865
33 18 636978
4 57 982955
25...

output:

0
-1
-1
209915
558666
-1
-1
83200
611952
-1
1048309
-1
-1
-1
585015
360875
143830
-1
-1
328671
-1
181594
816163
-1
-1
370881
-1
-1
-1
-1
-1
901354
877700
-1
-1
641912
-1
647817
1139824
488826
-1
929959
445997
168855
1199090
-1
-1
444234
1086853
850916
-1
-1
-1
-1
1070059
-1
846290
-1
116243
663538
1...

result:

ok 4900 lines

Test #9:

score: 0
Accepted
time: 17ms
memory: 5248kb

input:

70 490
50 30 591339
38 8 564617
11 63 805095
61 29 69176
19 35 453990
28 50 672168
26 57 541776
63 15 307625
65 15 747996
5 17 414836
43 18 776234
29 69 734517
39 51 959948
45 62 933398
9 9 132078
20 23 921720
41 68 749130
38 6 378417
54 23 563031
2 49 665025
45 42 901865
33 18 636978
4 57 982955
25...

output:

0
1182101
455385
209915
558666
667248
554176
83200
449623
1158035
1048309
975543
1640150
908459
585015
360875
143830
776709
1407301
328671
788905
181594
816163
1134974
1553891
370881
-1
458256
1189073
529892
1136659
893723
724122
629933
1241745
576043
696219
647817
1139824
488826
-1
468565
445997
16...

result:

ok 4900 lines

Test #10:

score: 0
Accepted
time: 16ms
memory: 5144kb

input:

70 1225
16 10 8
9 42 8
1 25 2
37 32 5
70 62 10
68 9 3
60 46 5
37 42 3
68 37 6
7 13 5
48 59 9
11 43 6
67 37 5
46 40 3
62 68 6
50 46 1
64 26 2
32 57 4
54 41 10
67 17 3
21 36 6
67 54 2
23 11 2
10 16 5
6 67 7
15 13 7
15 43 6
15 30 7
64 21 3
44 33 2
67 19 8
28 50 2
63 49 1
17 54 9
6 44 10
31 50 5
50 39 1...

output:

0
4
8
1
1
10
11
7
-1
5
9
6149
11
11
6
10
4
8
14
-1
12
-1
10
12
8514
8
10
14
12
20
7
2
11
9
15
7
14
6
4074
7
7
11
9
7
8
16
6
8203
8
10
3
14
10
13
7
2
-1
7
14
8
5
3
11
6
12
7
5
2
13
13
9
0
4075
-1
6
4
12
7
8
11
4071
-1
3
20
2
6
11
8
2360
11
11
10
2361
10
8
15
16
3463
13
8
14
12
9
12
7
6
10
11
4070
8
1...

result:

ok 4900 lines

Test #11:

score: 0
Accepted
time: 16ms
memory: 5308kb

input:

70 1225
16 10 8
9 42 8
1 25 2
37 32 5
70 62 10
68 9 3
60 46 5
37 42 3
68 37 6
7 13 5
48 59 9
11 43 6
67 37 5
46 40 3
62 68 6
50 46 1
64 26 2
32 57 4
54 41 10
67 17 3
21 36 6
67 54 2
23 11 2
10 16 5
6 67 7
15 13 7
15 43 6
15 30 7
64 21 3
44 33 2
67 19 8
28 50 2
63 49 1
17 54 9
6 44 10
31 50 5
50 39 1...

output:

0
4
8
1
1
8
3
7
9
5
7
6
4
8
6
9
4
8
5
10
8
14
10
8
5
8
9
12
7
7
7
2
4
9
6
7
7
6
10
7
7
10
9
7
7
10
6
3
7
10
3
8
3
8
7
2
7
5
4
8
5
3
6
3
7
5
5
2
9
8
7
0
10
10
6
4
8
4
8
4
9
7
3
6
2
6
6
8
10
8
9
10
9
10
8
13
9
7
9
8
8
8
8
10
7
6
6
5
13
8
9
10
12
8
3
6
5
5
6
7
8
10
7
4
6
6
9
9
5
5
8
7
7
5
8
3
1
4
7
5
6...

result:

ok 4900 lines

Test #12:

score: 0
Accepted
time: 12ms
memory: 5360kb

input:

70 5390
52 19 10
70 53 5
1 12 5
66 9 7
12 12 7
3 53 3
63 1 6
11 12 9
38 38 9
7 26 2
61 65 6
17 32 7
11 59 6
6 43 9
19 29 9
5 37 5
24 50 10
38 26 6
14 21 6
39 44 1
63 9 2
64 27 8
59 3 4
17 60 6
23 12 7
43 29 2
18 17 3
41 17 8
51 66 9
62 23 3
35 65 7
43 20 7
19 14 1
50 69 4
2 29 5
52 29 7
56 58 5
21 4...

output:

0
13
141
114
10
16
18
120
132
11
9
119
11
248
13
116
163
320
17
121
128
10
126
217
153
12
18
198
8
9
112
137
10
6
392
185
9
122
140
222
136
11
10
120
117
18
108
19
134
8
210
10
123
109
9
14
15
12
15
106
106
210
6
132
11
110
9
11
109
230
106
0
3
14
6
275
156
6
115
140
9
13
133
8
4
162
149
312
8
14
13...

result:

ok 4900 lines

Test #13:

score: 0
Accepted
time: 12ms
memory: 5304kb

input:

70 5390
52 19 10
70 53 5
1 12 5
66 9 7
12 12 7
3 53 3
63 1 6
11 12 9
38 38 9
7 26 2
61 65 6
17 32 7
11 59 6
6 43 9
19 29 9
5 37 5
24 50 10
38 26 6
14 21 6
39 44 1
63 9 2
64 27 8
59 3 4
17 60 6
23 12 7
43 29 2
18 17 3
41 17 8
51 66 9
62 23 3
35 65 7
43 20 7
19 14 1
50 69 4
2 29 5
52 29 7
56 58 5
21 4...

output:

0
13
16
18
10
16
14
18
15
11
9
24
11
14
13
17
19
18
17
17
12
10
15
10
19
12
18
21
8
9
13
28
10
6
17
15
9
18
13
13
19
11
10
20
17
15
24
16
24
8
12
10
19
16
9
14
11
12
15
11
12
18
6
13
11
11
9
11
18
16
9
0
3
11
6
16
7
6
11
8
7
13
8
8
4
15
8
9
8
14
13
6
6
8
9
6
15
9
8
1
16
23
12
7
8
7
7
12
11
5
6
9
9
1...

result:

ok 4900 lines

Subtask #3:

score: 25
Accepted

Test #14:

score: 25
Accepted
time: 16ms
memory: 5252kb

input:

70 490
40 26 225705
64 20 951862
65 54 193523
70 2 962697
9 17 841338
37 69 610559
1 3 722994
68 41 176421
39 53 620000
30 8 551483
33 47 222835
51 8 238052
1 14 154265
63 15 999850
40 23 348332
30 49 309530
9 24 270462
59 41 282265
6 30 483892
17 45 885409
36 30 51363
25 35 891076
70 30 284836
63 6...

output:

0
238410
537267
445497
656955
476527
518332
634481
369643
552714
533599
346403
1093460
895009
355634
261515
272941
235620
469154
259595
417982
366857
289866
463372
345462
378121
885894
163209
861555
227151
831651
255724
739566
360265
502089
278514
353702
642352
483900
231595
819076
718670
217848
616...

result:

ok 4900 lines

Test #15:

score: 0
Accepted
time: 16ms
memory: 5324kb

input:

70 490
40 26 225705
64 20 951862
65 54 193523
70 2 962697
9 17 841338
37 69 610559
1 3 722994
68 41 176421
39 53 620000
30 8 551483
33 47 222835
51 8 238052
1 14 154265
63 15 999850
40 23 348332
30 49 309530
9 24 270462
59 41 282265
6 30 483892
17 45 885409
36 30 51363
25 35 891076
70 30 284836
63 6...

output:

0
238410
537267
445497
656955
476527
518332
634481
369643
552714
533599
346403
1093460
895009
355634
261515
272941
235620
469154
259595
417982
366857
289866
463372
345462
378121
885894
163209
861555
227151
831651
255724
739566
360265
502089
278514
353702
642352
483900
231595
819076
718670
217848
616...

result:

ok 4900 lines

Test #16:

score: 0
Accepted
time: 10ms
memory: 5276kb

input:

70 1225
70 62 1
60 27 10
32 34 9
52 52 10
17 40 8
34 3 7
15 5 6
39 63 5
23 22 9
28 35 10
8 39 2
48 59 6
56 38 4
65 14 6
59 35 7
2 62 6
54 6 4
42 66 3
13 58 2
5 51 8
16 27 1
31 62 7
1 34 5
15 7 7
30 63 8
2 26 8
30 45 10
59 11 10
46 37 1
52 28 7
59 37 5
18 69 1
36 34 6
7 68 8
36 41 5
12 19 5
46 61 10
...

output:

0
5
5
1
3
5
7
5
3
6
3
1
3
6
2
3
6
4
6
6
5
9
3
7
4
5
4
3
4
4
7
8
5
6
5
5
6
4
6
6
7
6
3
6
4
6
6
5
6
3
5
7
5
6
5
8
5
6
7
4
2
7
5
5
4
5
6
4
5
2
4
0
5
5
8
5
5
6
6
4
7
5
3
6
2
5
6
7
7
8
3
5
4
8
5
8
4
5
6
6
7
8
2
8
6
7
3
7
5
6
5
5
7
8
5
4
7
4
4
3
7
5
6
7
5
8
3
1
6
4
6
6
6
6
4
5
5
4
6
4
5
3
0
4
5
2
6
1
4
3
...

result:

ok 4900 lines

Test #17:

score: 0
Accepted
time: 8ms
memory: 5212kb

input:

70 1225
70 62 1
60 27 10
32 34 9
52 52 10
17 40 8
34 3 7
15 5 6
39 63 5
23 22 9
28 35 10
8 39 2
48 59 6
56 38 4
65 14 6
59 35 7
2 62 6
54 6 4
42 66 3
13 58 2
5 51 8
16 27 1
31 62 7
1 34 5
15 7 7
30 63 8
2 26 8
30 45 10
59 11 10
46 37 1
52 28 7
59 37 5
18 69 1
36 34 6
7 68 8
36 41 5
12 19 5
46 61 10
...

output:

0
5
5
1
3
5
7
5
3
6
3
1
3
6
2
3
6
4
6
6
5
7
3
7
4
5
4
3
4
4
7
8
5
6
5
5
6
4
6
6
7
5
3
6
4
6
6
5
6
3
5
7
5
6
5
8
5
6
7
4
2
7
5
5
4
5
6
4
5
2
4
0
5
5
6
5
5
6
6
4
7
5
3
6
2
5
6
7
7
7
3
5
4
8
5
8
4
5
6
6
7
8
2
8
6
7
3
7
5
6
5
5
7
8
5
4
7
4
4
3
7
5
6
7
5
8
3
1
6
4
6
6
6
6
4
5
5
4
6
4
5
3
0
4
5
2
6
1
4
3
...

result:

ok 4900 lines

Test #18:

score: 0
Accepted
time: 12ms
memory: 5272kb

input:

70 5390
68 33 8
49 65 2
68 40 4
62 7 3
64 23 6
34 62 5
3 16 9
70 55 1
1 20 3
56 19 1
18 12 1
63 39 5
19 63 2
55 44 8
47 59 9
20 57 4
7 41 6
28 65 10
33 23 9
20 35 10
54 4 3
18 27 4
48 47 3
40 64 5
59 55 3
70 68 4
22 47 4
64 42 7
66 26 10
42 65 1
49 11 8
40 70 7
52 60 4
62 56 7
54 4 5
52 31 10
45 57 ...

output:

0
11
9
10
17
11
8
12
7
9
13
12
12
11
6
8
9
9
10
5
10
8
6
10
4
8
9
9
9
10
13
1
9
6
6
14
8
8
4
16
3
10
5
11
5
14
7
10
11
13
9
12
6
8
11
10
1
7
14
8
11
10
8
12
12
11
5
9
5
10
11
0
14
14
21
9
12
15
10
8
14
13
6
10
9
13
12
14
8
8
8
5
9
11
9
11
10
3
11
9
11
12
14
5
17
15
7
11
12
15
6
14
10
7
8
13
13
3
12
...

result:

ok 4900 lines

Test #19:

score: 0
Accepted
time: 18ms
memory: 5340kb

input:

70 5390
68 33 8
49 65 2
68 40 4
62 7 3
64 23 6
34 62 5
3 16 9
70 55 1
1 20 3
56 19 1
18 12 1
63 39 5
19 63 2
55 44 8
47 59 9
20 57 4
7 41 6
28 65 10
33 23 9
20 35 10
54 4 3
18 27 4
48 47 3
40 64 5
59 55 3
70 68 4
22 47 4
64 42 7
66 26 10
42 65 1
49 11 8
40 70 7
52 60 4
62 56 7
54 4 5
52 31 10
45 57 ...

output:

0
11
9
10
17
11
8
12
7
9
13
12
12
11
6
8
9
9
10
5
10
8
6
10
4
8
9
9
9
10
13
1
9
6
6
14
8
8
4
16
3
10
5
11
5
14
7
10
11
13
9
12
6
8
11
10
1
7
14
8
11
10
8
12
12
11
5
9
5
10
11
0
14
14
21
9
12
15
10
8
14
13
6
10
9
13
12
14
8
8
8
5
9
11
9
11
10
3
11
9
11
12
14
5
17
15
7
11
12
15
6
14
10
7
8
13
13
3
12
...

result:

ok 4900 lines

Test #20:

score: 0
Accepted
time: 111ms
memory: 5284kb

input:

70 490980
63 58 10
11 62 1
1 61 4
23 1 1
52 19 3
37 54 1
16 29 5
42 49 3
49 19 9
70 49 3
45 37 4
10 65 9
12 33 3
19 2 9
45 44 1
5 68 1
32 47 3
64 36 6
35 47 2
48 25 4
17 50 7
23 62 1
25 39 10
62 36 6
64 24 9
29 42 6
2 50 10
53 57 2
17 59 7
4 8 5
68 17 2
40 25 1
68 66 8
49 33 10
6 57 1
60 29 6
9 49 8...

output:

0
3
3
6
4
5
6
3
6
5
3
2
4
2
5
3
4
4
4
2
3
2
1
3
5
1
3
3
5
1
4
4
3
4
2
4
2
5
3
3
4
6
2
5
5
4
3
2
3
3
3
4
2
1
5
4
4
5
4
4
2
4
4
7
5
2
4
5
4
3
3
0
1
8
5
5
5
4
5
4
5
2
5
5
6
4
7
3
4
2
6
5
4
2
6
1
3
6
2
4
3
5
3
1
4
4
5
6
5
2
4
7
1
2
3
7
7
3
4
4
3
5
5
4
8
5
4
7
4
5
2
6
4
6
8
5
2
6
7
5
5
7
0
8
7
7
9
4
6
6
...

result:

ok 4900 lines

Test #21:

score: 0
Accepted
time: 89ms
memory: 5284kb

input:

70 490980
63 58 10
11 62 1
1 61 4
23 1 1
52 19 3
37 54 1
16 29 5
42 49 3
49 19 9
70 49 3
45 37 4
10 65 9
12 33 3
19 2 9
45 44 1
5 68 1
32 47 3
64 36 6
35 47 2
48 25 4
17 50 7
23 62 1
25 39 10
62 36 6
64 24 9
29 42 6
2 50 10
53 57 2
17 59 7
4 8 5
68 17 2
40 25 1
68 66 8
49 33 10
6 57 1
60 29 6
9 49 8...

output:

0
3
3
6
4
5
6
3
6
5
3
2
4
2
5
3
4
4
4
2
3
2
1
3
5
1
3
3
5
1
4
4
3
4
2
4
2
5
3
3
4
6
2
5
5
4
3
2
3
3
3
4
2
1
5
4
4
5
4
4
2
4
4
7
5
2
4
5
4
3
3
0
1
8
5
5
5
4
5
4
5
2
5
5
5
4
7
3
4
2
6
5
4
2
6
1
3
6
2
4
3
5
3
1
4
4
5
6
5
2
4
7
1
2
3
7
6
3
4
4
3
5
5
4
7
5
4
7
4
5
2
6
4
6
8
5
2
6
7
5
5
7
0
8
7
7
9
4
6
6
...

result:

ok 4900 lines

Test #22:

score: 0
Accepted
time: 98ms
memory: 5252kb

input:

70 490980
63 58 10
11 62 1
1 61 4
23 1 1
52 19 3
37 54 1
16 29 5
42 49 3
49 19 9
70 49 3
45 37 4
10 65 9
12 33 3
19 2 9
45 44 1
5 68 1
32 47 3
64 36 6
35 47 2
48 25 4
17 50 7
23 62 1
25 39 10
62 36 6
64 24 9
29 42 6
2 50 10
53 57 2
17 59 7
4 8 5
68 17 2
40 25 1
68 66 8
49 33 10
6 57 1
60 29 6
9 49 8...

output:

0
3
3
6
4
5
6
3
6
5
3
2
4
2
5
3
4
4
4
2
3
2
1
3
5
1
3
3
5
1
4
4
3
4
2
4
2
5
3
3
4
6
2
5
5
4
3
2
3
3
3
4
2
1
5
4
4
5
4
4
2
4
4
7
5
2
4
5
4
3
3
0
1
8
5
5
5
4
5
4
5
2
5
5
5
4
7
3
4
2
6
5
4
2
6
1
3
6
2
4
3
5
3
1
4
4
5
6
5
2
4
7
1
2
3
7
6
3
4
4
3
5
5
4
7
5
4
7
4
5
2
6
4
6
8
5
2
6
7
5
5
7
0
8
7
7
9
4
6
6
...

result:

ok 4900 lines

Test #23:

score: 0
Accepted
time: 100ms
memory: 5264kb

input:

70 490980
63 58 10
11 62 1
1 61 4
23 1 1
52 19 3
37 54 1
16 29 5
42 49 3
49 19 9
70 49 3
45 37 4
10 65 9
12 33 3
19 2 9
45 44 1
5 68 1
32 47 3
64 36 6
35 47 2
48 25 4
17 50 7
23 62 1
25 39 10
62 36 6
64 24 9
29 42 6
2 50 10
53 57 2
17 59 7
4 8 5
68 17 2
40 25 1
68 66 8
49 33 10
6 57 1
60 29 6
9 49 8...

output:

0
3
3
6
4
5
6
3
6
5
3
2
4
2
5
3
4
4
4
2
3
2
1
3
5
1
3
3
5
1
4
4
3
4
2
4
2
5
3
3
4
6
2
5
5
4
3
2
3
3
3
4
2
1
5
4
4
5
4
4
2
4
4
7
5
2
4
5
4
3
3
0
1
8
5
5
5
4
5
4
5
2
5
5
5
4
7
3
4
2
6
5
4
2
6
1
3
6
2
4
3
5
3
1
4
4
5
6
5
2
4
7
1
2
3
7
6
3
4
4
3
5
5
4
7
5
4
7
4
5
2
6
4
6
8
5
2
6
7
5
5
7
0
8
7
7
9
4
6
6
...

result:

ok 4900 lines

Test #24:

score: 0
Accepted
time: 84ms
memory: 5212kb

input:

70 499800
4 37 4
6 40 3
14 64 10
42 54 6
12 55 3
65 19 10
63 42 6
35 8 5
13 36 1
32 52 10
50 67 8
28 26 7
34 26 6
52 53 10
39 66 9
46 9 5
29 70 1
10 46 10
67 46 9
48 22 7
7 64 6
60 46 9
50 13 8
26 1 5
47 34 9
18 11 10
17 42 7
40 44 9
70 15 5
8 57 3
51 57 10
1 67 4
22 11 1
37 34 8
44 38 7
12 3 7
54 2...

output:

0
2
2
3
3
2
3
3
2
2
2
3
3
3
3
1
3
3
2
3
3
3
3
2
3
1
2
2
3
3
3
3
3
3
2
2
2
1
2
3
2
2
2
3
2
3
3
2
2
3
2
3
2
2
1
2
3
1
2
3
3
2
3
2
2
1
3
2
3
3
2
0
2
3
3
2
3
3
2
3
2
3
2
2
1
1
1
2
3
3
2
3
3
3
1
2
2
2
3
2
3
3
2
3
2
3
2
2
3
3
1
2
2
1
3
2
3
3
2
3
3
2
2
3
2
1
3
1
2
2
2
3
3
2
2
3
2
2
3
2
3
2
0
2
3
3
1
2
1
3
...

result:

ok 4900 lines

Test #25:

score: 0
Accepted
time: 93ms
memory: 5228kb

input:

70 499800
4 37 4
6 40 3
14 64 10
42 54 6
12 55 3
65 19 10
63 42 6
35 8 5
13 36 1
32 52 10
50 67 8
28 26 7
34 26 6
52 53 10
39 66 9
46 9 5
29 70 1
10 46 10
67 46 9
48 22 7
7 64 6
60 46 9
50 13 8
26 1 5
47 34 9
18 11 10
17 42 7
40 44 9
70 15 5
8 57 3
51 57 10
1 67 4
22 11 1
37 34 8
44 38 7
12 3 7
54 2...

output:

0
2
2
3
3
2
3
4
2
2
2
3
4
3
4
1
3
3
2
3
3
3
3
2
3
1
2
2
4
5
4
3
3
3
2
2
2
1
2
3
2
2
2
3
2
3
3
2
2
3
2
3
2
2
1
2
3
1
2
3
3
2
3
2
2
1
3
2
3
4
2
0
2
3
3
2
3
4
2
4
2
3
2
2
1
1
1
2
3
3
2
4
3
3
1
2
2
2
3
2
4
3
2
5
2
3
2
2
3
3
1
2
2
1
4
2
3
4
2
3
4
2
2
3
2
1
3
1
2
2
2
3
3
2
2
3
2
2
3
2
4
2
0
2
3
3
1
2
1
3
...

result:

ok 4900 lines

Test #26:

score: 0
Accepted
time: 103ms
memory: 5144kb

input:

70 499800
4 37 4
6 40 3
14 64 10
42 54 6
12 55 3
65 19 10
63 42 6
35 8 5
13 36 1
32 52 10
50 67 8
28 26 7
34 26 6
52 53 10
39 66 9
46 9 5
29 70 1
10 46 10
67 46 9
48 22 7
7 64 6
60 46 9
50 13 8
26 1 5
47 34 9
18 11 10
17 42 7
40 44 9
70 15 5
8 57 3
51 57 10
1 67 4
22 11 1
37 34 8
44 38 7
12 3 7
54 2...

output:

0
2
2
3
3
2
3
3
2
2
2
3
3
3
3
1
3
3
2
3
3
3
3
2
3
1
2
2
3
3
3
3
3
3
2
2
2
1
2
3
2
2
2
3
2
3
3
2
2
3
2
3
2
2
1
2
3
1
2
3
3
2
3
2
2
1
3
2
3
3
2
0
2
3
3
2
3
3
2
3
2
3
2
2
1
1
1
2
3
3
2
3
3
3
1
2
2
2
3
2
3
3
2
3
2
3
2
2
3
3
1
2
2
1
3
2
3
3
2
3
3
2
2
3
2
1
3
1
2
2
2
3
3
2
2
3
2
2
3
2
3
2
0
2
3
3
1
2
1
3
...

result:

ok 4900 lines

Test #27:

score: 0
Accepted
time: 108ms
memory: 5140kb

input:

70 499800
4 37 4
6 40 3
14 64 10
42 54 6
12 55 3
65 19 10
63 42 6
35 8 5
13 36 1
32 52 10
50 67 8
28 26 7
34 26 6
52 53 10
39 66 9
46 9 5
29 70 1
10 46 10
67 46 9
48 22 7
7 64 6
60 46 9
50 13 8
26 1 5
47 34 9
18 11 10
17 42 7
40 44 9
70 15 5
8 57 3
51 57 10
1 67 4
22 11 1
37 34 8
44 38 7
12 3 7
54 2...

output:

0
2
2
3
3
2
3
3
2
2
2
3
3
3
3
1
3
3
2
3
3
3
3
2
3
1
2
2
3
3
3
3
3
3
2
2
2
1
2
3
2
2
2
3
2
3
3
2
2
3
2
3
2
2
1
2
3
1
2
3
3
2
3
2
2
1
3
2
3
3
2
0
2
3
3
2
3
3
2
3
2
3
2
2
1
1
1
2
3
3
2
3
3
3
1
2
2
2
3
2
3
3
2
3
2
3
2
2
3
3
1
2
2
1
3
2
3
3
2
3
3
2
2
3
2
1
3
1
2
2
2
3
3
2
2
3
2
2
3
2
3
2
0
2
3
3
1
2
1
3
...

result:

ok 4900 lines

Test #28:

score: 0
Accepted
time: 102ms
memory: 5228kb

input:

70 499800
51 54 13837
54 57 50077
20 25 81933
32 42 54992
7 52 31543
37 12 14100
21 9 61120
35 1 89664
54 43 89473
33 69 72144
17 14 23986
38 6 90258
25 54 55383
37 51 99517
15 62 54519
5 61 24171
23 56 33166
11 66 84132
40 15 58103
18 32 98478
58 51 69888
49 6 19787
21 41 81769
54 48 52342
27 66 10...

output:

0
35068
27338
18856
30133
37725
28146
23294
37462
37658
26013
34116
34373
38454
35038
33013
24872
38001
37078
23957
21774
33019
40567
24560
32778
26802
11010
28507
25089
29273
23408
31870
20437
24741
21559
32812
24090
25991
38171
33814
35083
22595
26222
25945
24261
13178
33539
33287
34106
38439
2226...

result:

ok 4900 lines

Test #29:

score: 0
Accepted
time: 89ms
memory: 5276kb

input:

70 499800
51 54 13837
54 57 50077
20 25 81933
32 42 54992
7 52 31543
37 12 14100
21 9 61120
35 1 89664
54 43 89473
33 69 72144
17 14 23986
38 6 90258
25 54 55383
37 51 99517
15 62 54519
5 61 24171
23 56 33166
11 66 84132
40 15 58103
18 32 98478
58 51 69888
49 6 19787
21 41 81769
54 48 52342
27 66 10...

output:

0
33350
27338
18856
30133
37007
28146
23294
32817
37658
26013
31014
34373
35794
35038
33013
24872
37106
37078
23957
21774
33019
36541
24560
32778
26802
11010
28507
25089
29273
23408
31870
20437
24741
21559
32812
24090
25991
33061
33814
35083
22595
26222
25945
24261
13178
33539
33287
34106
38439
2226...

result:

ok 4900 lines

Test #30:

score: 0
Accepted
time: 109ms
memory: 5252kb

input:

70 499800
51 54 13837
54 57 50077
20 25 81933
32 42 54992
7 52 31543
37 12 14100
21 9 61120
35 1 89664
54 43 89473
33 69 72144
17 14 23986
38 6 90258
25 54 55383
37 51 99517
15 62 54519
5 61 24171
23 56 33166
11 66 84132
40 15 58103
18 32 98478
58 51 69888
49 6 19787
21 41 81769
54 48 52342
27 66 10...

output:

0
33350
27338
18856
30133
37007
28146
23294
32817
37658
26013
31014
34373
35794
35038
33013
24872
37106
37078
23957
21774
33019
36541
24560
32778
26802
11010
28507
25089
29273
23408
31870
20437
24741
21559
32812
24090
25991
33061
33814
35083
22595
26222
25945
24261
13178
33539
33287
34106
38439
2226...

result:

ok 4900 lines

Test #31:

score: 0
Accepted
time: 92ms
memory: 5284kb

input:

70 499800
51 54 13837
54 57 50077
20 25 81933
32 42 54992
7 52 31543
37 12 14100
21 9 61120
35 1 89664
54 43 89473
33 69 72144
17 14 23986
38 6 90258
25 54 55383
37 51 99517
15 62 54519
5 61 24171
23 56 33166
11 66 84132
40 15 58103
18 32 98478
58 51 69888
49 6 19787
21 41 81769
54 48 52342
27 66 10...

output:

0
33350
27338
18856
30133
37007
28146
23294
32817
37658
26013
31014
34373
35794
35038
33013
24872
37106
37078
23957
21774
33019
36541
24560
32778
26802
11010
28507
25089
29273
23408
31870
20437
24741
21559
32812
24090
25991
33061
33814
35083
22595
26222
25945
24261
13178
33539
33287
34106
38439
2226...

result:

ok 4900 lines

Test #32:

score: 0
Accepted
time: 107ms
memory: 5308kb

input:

70 514500
62 20 7
66 48 60
1 37 13
44 63 56
33 50 93
40 6 45
16 36 25
22 58 4
26 18 89
6 28 40
45 12 49
1 7 89
61 49 31
25 9 1
32 59 3
23 25 99
26 36 32
60 20 60
55 46 56
55 67 41
6 5 14
47 7 3
15 14 87
37 50 71
49 14 73
18 11 78
1 4 50
48 64 79
34 69 3
16 57 8
48 42 79
56 5 55
28 26 27
11 27 16
42 ...

output:

0
4
4
3
3
4
3
4
4
3
4
5
5
3
5
5
4
2
6
3
4
5
4
7
3
3
5
5
5
2
4
2
2
5
5
5
5
4
3
3
4
5
3
1
4
4
5
5
4
3
3
5
2
4
4
2
3
1
3
6
5
4
2
4
6
3
5
4
6
4
3
0
2
2
1
1
3
2
3
2
2
3
2
2
4
3
3
3
3
2
2
6
2
5
3
2
3
2
4
4
4
3
3
3
3
3
3
3
3
3
3
3
1
2
3
2
3
2
1
3
1
2
2
3
1
3
4
3
4
3
3
3
2
3
3
3
2
2
3
1
3
3
0
5
5
5
4
2
6
5
...

result:

ok 4900 lines

Test #33:

score: 0
Accepted
time: 101ms
memory: 5260kb

input:

70 514500
62 20 7
66 48 60
1 37 13
44 63 56
33 50 93
40 6 45
16 36 25
22 58 4
26 18 89
6 28 40
45 12 49
1 7 89
61 49 31
25 9 1
32 59 3
23 25 99
26 36 32
60 20 60
55 46 56
55 67 41
6 5 14
47 7 3
15 14 87
37 50 71
49 14 73
18 11 78
1 4 50
48 64 79
34 69 3
16 57 8
48 42 79
56 5 55
28 26 27
11 27 16
42 ...

output:

0
4
4
3
3
4
3
4
4
3
4
5
5
3
5
4
4
2
4
3
4
5
4
5
3
3
4
4
5
2
4
2
2
5
5
4
5
4
3
3
4
5
3
1
4
4
5
4
4
3
3
4
2
4
4
2
3
1
3
4
5
4
2
4
5
3
4
4
6
4
3
0
2
2
1
1
3
2
3
2
2
3
2
2
4
3
3
3
3
2
2
4
2
5
3
2
3
2
4
4
4
3
3
3
3
3
3
3
3
3
3
3
1
2
3
2
3
2
1
3
1
2
2
3
1
3
4
3
4
3
3
3
2
3
3
3
2
2
3
1
3
3
0
5
4
4
4
2
5
5
...

result:

ok 4900 lines

Test #34:

score: 0
Accepted
time: 105ms
memory: 5252kb

input:

70 514500
62 20 7
66 48 60
1 37 13
44 63 56
33 50 93
40 6 45
16 36 25
22 58 4
26 18 89
6 28 40
45 12 49
1 7 89
61 49 31
25 9 1
32 59 3
23 25 99
26 36 32
60 20 60
55 46 56
55 67 41
6 5 14
47 7 3
15 14 87
37 50 71
49 14 73
18 11 78
1 4 50
48 64 79
34 69 3
16 57 8
48 42 79
56 5 55
28 26 27
11 27 16
42 ...

output:

0
4
4
3
3
4
3
4
4
3
4
5
5
3
5
4
4
2
4
3
4
5
4
5
3
3
4
4
5
2
4
2
2
5
5
4
5
4
3
3
4
5
3
1
4
4
5
4
4
3
3
4
2
4
4
2
3
1
3
4
5
4
2
4
5
3
4
4
6
4
3
0
2
2
1
1
3
2
3
2
2
3
2
2
4
3
3
3
3
2
2
4
2
5
3
2
3
2
4
4
4
3
3
3
3
3
3
3
3
3
3
3
1
2
3
2
3
2
1
3
1
2
2
3
1
3
4
3
4
3
3
3
2
3
3
3
2
2
3
1
3
3
0
5
4
4
4
2
5
5
...

result:

ok 4900 lines

Test #35:

score: 0
Accepted
time: 113ms
memory: 5284kb

input:

70 514500
62 20 7
66 48 60
1 37 13
44 63 56
33 50 93
40 6 45
16 36 25
22 58 4
26 18 89
6 28 40
45 12 49
1 7 89
61 49 31
25 9 1
32 59 3
23 25 99
26 36 32
60 20 60
55 46 56
55 67 41
6 5 14
47 7 3
15 14 87
37 50 71
49 14 73
18 11 78
1 4 50
48 64 79
34 69 3
16 57 8
48 42 79
56 5 55
28 26 27
11 27 16
42 ...

output:

0
4
4
3
3
4
3
4
4
3
4
5
5
3
5
4
4
2
4
3
4
5
4
5
3
3
4
4
5
2
4
2
2
5
5
4
5
4
3
3
4
5
3
1
4
4
5
4
4
3
3
4
2
4
4
2
3
1
3
4
5
4
2
4
5
3
4
4
6
4
3
0
2
2
1
1
3
2
3
2
2
3
2
2
4
3
3
3
3
2
2
4
2
5
3
2
3
2
4
4
4
3
3
3
3
3
3
3
3
3
3
3
1
2
3
2
3
2
1
3
1
2
2
3
1
3
4
3
4
3
3
3
2
3
3
3
2
2
3
1
3
3
0
5
4
4
4
2
5
5
...

result:

ok 4900 lines

Test #36:

score: 0
Accepted
time: 92ms
memory: 5276kb

input:

70 490069
8 55 5
55 5 8
5 45 10
45 31 3
31 32 8
32 66 2
66 64 10
64 33 3
33 43 1
43 54 10
54 69 2
69 20 4
20 29 10
29 63 2
63 37 8
37 49 6
49 40 1
40 58 1
58 3 2
3 30 4
30 11 1
11 47 6
47 38 5
38 42 10
42 22 7
22 48 2
48 65 5
65 15 3
15 27 2
27 70 7
70 17 8
17 14 9
14 19 6
19 39 1
39 12 1
12 59 2
59...

output:

0
18
1058
28
1608
1197
2220
1214
35
2095
1053
1479
1493
1254
2034
1901
1263
8
1141
2162
2360
1859
1037
1879
1054
1312
1901
2230
2363
1054
2167
1637
1345
1307
2236
1302
1492
1876
1140
1113
40
1866
1344
1201
2170
1881
2554
1857
2177
1888
1320
2096
1891
1334
1209
1042
1050
1060
1534
1039
2209
1527
2296...

result:

ok 4900 lines

Test #37:

score: 0
Accepted
time: 104ms
memory: 5260kb

input:

70 490069
8 55 5
55 5 8
5 45 10
45 31 3
31 32 8
32 66 2
66 64 10
64 33 3
33 43 1
43 54 10
54 69 2
69 20 4
20 29 10
29 63 2
63 37 8
37 49 6
49 40 1
40 58 1
58 3 2
3 30 4
30 11 1
11 47 6
47 38 5
38 42 10
42 22 7
22 48 2
48 65 5
65 15 3
15 27 2
27 70 7
70 17 8
17 14 9
14 19 6
19 39 1
39 12 1
12 59 2
59...

output:

0
18
1058
28
1142
1127
45
1143
35
103
1053
1067
1062
1075
1111
94
1084
8
1069
1088
1348
1183
1037
72
1054
1050
1109
55
1078
1054
1129
1121
1105
1045
61
1040
1068
1143
1068
1061
40
1190
1104
1131
1132
1059
1148
1119
1062
81
1058
66
84
1094
1138
1042
1050
1060
1065
1039
1107
102
1076
1117
1114
1127
10...

result:

ok 4900 lines

Test #38:

score: 0
Accepted
time: 105ms
memory: 5408kb

input:

70 490069
8 55 5
55 5 8
5 45 10
45 31 3
31 32 8
32 66 2
66 64 10
64 33 3
33 43 1
43 54 10
54 69 2
69 20 4
20 29 10
29 63 2
63 37 8
37 49 6
49 40 1
40 58 1
58 3 2
3 30 4
30 11 1
11 47 6
47 38 5
38 42 10
42 22 7
22 48 2
48 65 5
65 15 3
15 27 2
27 70 7
70 17 8
17 14 9
14 19 6
19 39 1
39 12 1
12 59 2
59...

output:

0
18
1058
28
1141
117
45
1143
35
103
1053
160
1062
168
194
94
177
8
162
1088
1217
204
1037
72
1054
143
192
55
1078
1054
1128
1120
1105
138
61
133
1068
221
161
1061
40
211
1104
121
1131
1059
1133
202
1062
81
151
66
84
1094
1138
1042
1050
1060
158
1039
110
102
1076
1108
197
1118
1068
126
1092
185
1170...

result:

ok 4900 lines

Test #39:

score: 0
Accepted
time: 100ms
memory: 5328kb

input:

70 490069
8 55 5
55 5 8
5 45 10
45 31 3
31 32 8
32 66 2
66 64 10
64 33 3
33 43 1
43 54 10
54 69 2
69 20 4
20 29 10
29 63 2
63 37 8
37 49 6
49 40 1
40 58 1
58 3 2
3 30 4
30 11 1
11 47 6
47 38 5
38 42 10
42 22 7
22 48 2
48 65 5
65 15 3
15 27 2
27 70 7
70 17 8
17 14 9
14 19 6
19 39 1
39 12 1
12 59 2
59...

output:

0
18
237
28
320
117
45
333
35
103
232
160
1062
168
194
94
177
8
162
267
1217
204
1037
72
1054
143
192
55
257
233
307
299
284
138
61
133
247
221
161
240
40
211
283
121
310
1059
226
202
241
81
151
66
84
273
328
1042
1050
239
158
1039
110
102
255
287
197
297
1068
126
271
185
1170
0
219
10
302
99
27
315...

result:

ok 4900 lines

Subtask #4:

score: 15
Accepted

Test #40:

score: 15
Accepted
time: 9ms
memory: 5356kb

input:

70 490
19 30 878432
51 19 559375
59 36 559537
43 36 377542
5 53 628277
56 53 217836
11 53 310015
32 10 145520
35 35 259760
24 58 534354
22 28 319817
40 13 633062
5 11 650863
54 35 822751
62 62 747819
64 26 450949
59 58 998615
29 10 759770
70 52 615310
45 62 56002
57 28 684470
50 39 413941
39 41 4450...

output:

0
1013871
981980
998488
1199690
1124223
1157943
1216333
1209356
1079286
993638
1038959
845425
894300
1192579
800175
1257411
1045485
1020908
1082299
750220
1122433
1601027
399948
1068197
927980
1365068
1162273
763756
831024
1287646
832568
889688
1074696
973254
1162706
1072933
1154468
820965
1118384
1...

result:

ok 4900 lines

Test #41:

score: 0
Accepted
time: 16ms
memory: 5280kb

input:

70 490
19 30 878432
51 19 559375
59 36 559537
43 36 377542
5 53 628277
56 53 217836
11 53 310015
32 10 145520
35 35 259760
24 58 534354
22 28 319817
40 13 633062
5 11 650863
54 35 822751
62 62 747819
64 26 450949
59 58 998615
29 10 759770
70 52 615310
45 62 56002
57 28 684470
50 39 413941
39 41 4450...

output:

0
1013871
981980
998488
1199690
1124223
1157943
1216333
1209356
1079286
993638
1038959
845425
894300
1192579
800175
1257411
1045485
1020908
1082299
750220
1122433
1601027
399948
1068197
927980
1365068
1162273
763756
831024
1287646
832568
889688
1074696
973254
1162706
1072933
1154468
820965
1118384
1...

result:

ok 4900 lines

Test #42:

score: 0
Accepted
time: 12ms
memory: 5340kb

input:

70 1225
30 2 3
9 19 6
17 9 5
40 57 2
18 15 3
39 60 3
43 58 10
48 69 3
10 49 9
62 4 10
57 59 4
33 59 5
70 47 3
62 5 4
29 21 1
24 59 5
29 35 7
26 66 3
4 66 6
34 46 6
32 41 6
32 43 2
63 6 6
17 21 8
27 21 1
54 3 7
7 29 7
23 34 10
45 17 9
7 10 5
51 48 4
62 45 6
3 32 1
39 19 3
9 1 3
24 33 1
49 11 7
59 60 ...

output:

0
4
2
7
5
4
6
5
3
7
8
6
7
6
6
6
7
5
1
6
7
6
8
6
8
5
7
7
5
7
7
1
7
6
7
5
6
7
4
5
6
8
8
6
6
4
7
7
6
3
6
9
6
5
6
3
3
6
6
5
9
9
8
4
7
5
5
7
7
5
6
0
5
5
4
5
6
6
5
7
7
5
7
5
3
6
8
6
7
4
7
6
5
4
9
5
7
6
6
3
5
4
3
4
3
3
7
6
4
7
5
8
7
3
2
6
8
3
5
4
7
8
2
6
6
5
5
6
7
5
7
8
7
7
5
4
5
4
5
6
7
6
0
8
6
6
7
3
6
6
...

result:

ok 4900 lines

Test #43:

score: 0
Accepted
time: 16ms
memory: 5232kb

input:

70 1225
30 2 3
9 19 6
17 9 5
40 57 2
18 15 3
39 60 3
43 58 10
48 69 3
10 49 9
62 4 10
57 59 4
33 59 5
70 47 3
62 5 4
29 21 1
24 59 5
29 35 7
26 66 3
4 66 6
34 46 6
32 41 6
32 43 2
63 6 6
17 21 8
27 21 1
54 3 7
7 29 7
23 34 10
45 17 9
7 10 5
51 48 4
62 45 6
3 32 1
39 19 3
9 1 3
24 33 1
49 11 7
59 60 ...

output:

0
4
2
7
5
4
6
5
3
7
8
6
7
6
6
6
7
5
1
6
7
6
8
6
8
5
7
7
5
7
7
1
7
6
7
5
6
7
4
5
6
8
8
6
6
4
7
7
6
3
6
9
6
5
6
3
3
6
6
5
9
9
8
4
7
5
5
7
7
5
6
0
5
5
4
5
6
6
5
7
7
5
7
5
3
6
8
6
7
4
7
6
5
4
9
5
7
6
6
3
5
4
3
4
3
3
7
6
4
7
5
8
7
3
2
6
8
3
5
4
7
8
2
6
6
5
5
6
7
5
7
8
7
7
5
4
5
4
5
6
7
6
0
8
6
6
7
3
6
6
...

result:

ok 4900 lines

Test #44:

score: 0
Accepted
time: 17ms
memory: 5336kb

input:

70 5390
18 61 2
15 23 3
18 12 1
21 11 10
6 44 4
70 6 7
3 63 1
44 61 9
2 19 6
60 31 7
42 65 6
15 48 2
30 12 8
5 9 9
37 34 5
44 5 3
51 47 10
7 13 10
15 42 9
33 24 3
67 29 4
30 38 8
19 36 3
6 23 2
17 39 3
21 64 4
38 65 1
22 50 1
35 56 3
53 15 1
19 6 4
52 65 7
46 67 9
14 9 6
2 20 2
68 9 8
50 58 1
21 62 ...

output:

0
11
13
7
8
11
4
10
5
15
10
15
12
7
10
14
5
5
7
9
9
10
9
16
13
6
13
11
9
8
10
8
6
10
11
10
13
14
9
15
10
13
12
9
13
15
12
13
8
9
14
2
11
15
12
12
3
8
13
9
9
12
15
8
13
8
6
9
10
6
7
0
9
7
8
4
4
7
5
15
10
14
10
6
10
13
5
5
7
9
8
10
9
16
11
6
11
11
5
6
10
8
6
8
11
10
13
13
7
15
10
9
12
9
10
15
12
13
5
...

result:

ok 4900 lines

Test #45:

score: 0
Accepted
time: 12ms
memory: 5176kb

input:

70 5390
18 61 2
15 23 3
18 12 1
21 11 10
6 44 4
70 6 7
3 63 1
44 61 9
2 19 6
60 31 7
42 65 6
15 48 2
30 12 8
5 9 9
37 34 5
44 5 3
51 47 10
7 13 10
15 42 9
33 24 3
67 29 4
30 38 8
19 36 3
6 23 2
17 39 3
21 64 4
38 65 1
22 50 1
35 56 3
53 15 1
19 6 4
52 65 7
46 67 9
14 9 6
2 20 2
68 9 8
50 58 1
21 62 ...

output:

0
11
13
7
8
11
4
10
5
15
10
15
12
7
10
14
5
5
7
9
9
10
9
16
13
6
13
11
9
8
10
8
6
10
11
10
13
14
9
15
10
13
12
9
13
15
12
13
8
9
14
2
11
15
12
12
3
8
13
9
9
12
15
8
13
8
6
9
10
6
7
0
9
7
8
4
4
7
5
15
10
14
10
6
10
13
5
5
7
9
8
10
9
16
11
6
11
11
5
6
10
8
6
8
11
10
13
13
7
15
10
9
12
9
10
15
12
13
5
...

result:

ok 4900 lines

Test #46:

score: 0
Accepted
time: 106ms
memory: 5348kb

input:

70 490980
26 50 5
44 40 2
70 47 8
30 57 10
16 59 1
48 7 9
43 54 1
9 53 2
69 46 5
59 19 8
47 61 9
14 44 5
25 9 2
66 49 5
42 21 1
59 27 9
47 25 10
43 8 6
33 46 1
38 16 6
69 60 3
17 50 1
44 9 7
25 24 9
54 49 3
39 1 7
25 38 4
31 57 9
2 50 5
9 14 2
6 57 3
7 47 3
10 60 3
40 39 4
70 31 6
12 68 8
5 34 9
32 ...

output:

0
5
5
2
5
5
3
3
4
4
7
5
6
8
5
3
4
5
5
3
4
5
6
6
4
5
3
5
4
4
5
6
3
3
5
3
4
4
4
5
2
2
3
6
7
2
6
5
1
6
1
6
5
4
8
4
8
5
2
5
4
3
2
4
4
4
4
2
5
3
4
0
6
2
7
4
3
3
3
6
7
5
5
7
2
7
3
5
5
3
3
5
3
6
3
5
3
6
6
3
4
6
2
5
4
4
4
6
6
5
2
4
5
6
8
1
5
7
5
4
5
5
3
4
7
4
8
5
6
4
8
7
5
5
5
6
4
4
5
2
7
8
0
8
6
5
6
3
6
6
...

result:

ok 4900 lines

Test #47:

score: 0
Accepted
time: 95ms
memory: 5212kb

input:

70 490980
26 50 5
44 40 2
70 47 8
30 57 10
16 59 1
48 7 9
43 54 1
9 53 2
69 46 5
59 19 8
47 61 9
14 44 5
25 9 2
66 49 5
42 21 1
59 27 9
47 25 10
43 8 6
33 46 1
38 16 6
69 60 3
17 50 1
44 9 7
25 24 9
54 49 3
39 1 7
25 38 4
31 57 9
2 50 5
9 14 2
6 57 3
7 47 3
10 60 3
40 39 4
70 31 6
12 68 8
5 34 9
32 ...

output:

0
5
5
2
5
5
3
3
4
4
7
5
6
8
5
3
4
5
5
3
4
5
6
6
4
5
3
5
4
4
5
6
3
3
5
3
4
4
4
5
2
2
3
6
7
2
6
5
1
6
1
6
5
4
8
4
8
5
2
5
4
3
2
4
4
4
4
2
5
3
4
0
6
2
7
4
3
3
3
6
7
5
5
7
2
7
3
5
5
3
3
5
3
6
3
5
3
6
6
3
4
6
2
5
4
4
4
6
6
5
2
4
5
6
8
1
5
7
5
4
5
5
3
4
7
4
8
5
6
4
8
7
5
5
5
6
4
4
5
2
7
8
0
8
6
5
6
3
6
6
...

result:

ok 4900 lines

Test #48:

score: 0
Accepted
time: 113ms
memory: 5284kb

input:

70 490980
26 50 5
44 40 2
70 47 8
30 57 10
16 59 1
48 7 9
43 54 1
9 53 2
69 46 5
59 19 8
47 61 9
14 44 5
25 9 2
66 49 5
42 21 1
59 27 9
47 25 10
43 8 6
33 46 1
38 16 6
69 60 3
17 50 1
44 9 7
25 24 9
54 49 3
39 1 7
25 38 4
31 57 9
2 50 5
9 14 2
6 57 3
7 47 3
10 60 3
40 39 4
70 31 6
12 68 8
5 34 9
32 ...

output:

0
5
5
2
5
5
3
3
4
4
7
5
6
8
5
3
4
5
5
3
4
5
6
6
4
5
3
5
4
4
5
6
3
3
5
3
4
4
4
5
2
2
3
6
7
2
6
5
1
6
1
6
5
4
8
4
8
5
2
5
4
3
2
4
4
4
4
2
5
3
4
0
6
2
7
4
3
3
3
6
7
5
5
7
2
7
3
5
5
3
3
5
3
6
3
5
3
6
6
3
4
6
2
5
4
4
4
6
6
5
2
4
5
6
8
1
5
7
5
4
5
5
3
4
7
4
8
5
6
4
8
7
5
5
5
6
4
4
5
2
7
8
0
8
6
5
6
3
6
6
...

result:

ok 4900 lines

Test #49:

score: 0
Accepted
time: 94ms
memory: 5340kb

input:

70 490980
26 50 5
44 40 2
70 47 8
30 57 10
16 59 1
48 7 9
43 54 1
9 53 2
69 46 5
59 19 8
47 61 9
14 44 5
25 9 2
66 49 5
42 21 1
59 27 9
47 25 10
43 8 6
33 46 1
38 16 6
69 60 3
17 50 1
44 9 7
25 24 9
54 49 3
39 1 7
25 38 4
31 57 9
2 50 5
9 14 2
6 57 3
7 47 3
10 60 3
40 39 4
70 31 6
12 68 8
5 34 9
32 ...

output:

0
5
5
2
5
5
3
3
4
4
7
5
6
8
5
3
4
5
5
3
4
5
6
6
4
5
3
5
4
4
5
6
3
3
5
3
4
4
4
5
2
2
3
6
7
2
6
5
1
6
1
6
5
4
8
4
8
5
2
5
4
3
2
4
4
4
4
2
5
3
4
0
6
2
7
4
3
3
3
6
7
5
5
7
2
7
3
5
5
3
3
5
3
6
3
5
3
6
6
3
4
6
2
5
4
4
4
6
6
5
2
4
5
6
8
1
5
7
5
4
5
5
3
4
7
4
8
5
6
4
8
7
5
5
5
6
4
4
5
2
7
8
0
8
6
5
6
3
6
6
...

result:

ok 4900 lines

Test #50:

score: 0
Accepted
time: 103ms
memory: 5276kb

input:

70 499800
24 63 10
67 32 1
55 47 1
52 50 8
48 32 5
25 56 7
22 45 3
37 3 1
30 32 5
2 8 1
6 37 3
40 30 9
53 16 5
35 65 9
54 51 7
29 54 1
35 55 1
12 44 2
26 51 1
30 47 8
24 7 4
10 60 2
32 16 2
62 40 9
63 5 10
61 1 6
9 25 10
7 21 4
37 42 10
47 11 10
10 54 7
19 20 5
64 16 9
41 19 3
17 52 10
7 30 3
48 33 ...

output:

0
2
2
3
2
2
2
3
3
3
1
2
3
3
3
2
3
2
2
3
3
3
2
3
3
2
3
2
2
1
3
3
3
3
2
3
3
3
3
2
2
3
2
2
2
2
3
3
2
1
2
3
2
3
3
3
3
2
1
2
2
3
2
1
4
2
3
3
2
3
3
0
1
4
2
1
2
2
3
3
1
2
2
3
3
2
3
2
3
2
3
3
1
3
3
2
3
3
3
1
3
3
2
3
2
3
2
3
3
3
3
3
2
2
2
3
3
3
3
2
3
3
2
2
3
1
3
3
3
3
2
3
3
1
4
3
3
3
2
2
2
2
0
3
1
3
4
1
2
2
...

result:

ok 4900 lines

Test #51:

score: 0
Accepted
time: 114ms
memory: 5260kb

input:

70 499800
24 63 10
67 32 1
55 47 1
52 50 8
48 32 5
25 56 7
22 45 3
37 3 1
30 32 5
2 8 1
6 37 3
40 30 9
53 16 5
35 65 9
54 51 7
29 54 1
35 55 1
12 44 2
26 51 1
30 47 8
24 7 4
10 60 2
32 16 2
62 40 9
63 5 10
61 1 6
9 25 10
7 21 4
37 42 10
47 11 10
10 54 7
19 20 5
64 16 9
41 19 3
17 52 10
7 30 3
48 33 ...

output:

0
2
2
3
2
2
2
3
3
3
1
2
3
3
3
2
3
2
2
3
3
3
2
3
3
2
3
2
2
1
3
3
3
3
2
3
3
3
3
2
2
3
2
2
2
2
3
3
2
1
2
3
2
3
3
3
3
2
1
2
2
3
2
1
4
2
3
3
2
3
3
0
1
4
2
1
2
2
3
3
1
2
2
3
3
2
3
2
3
2
3
3
1
3
3
2
3
3
3
1
3
3
2
3
2
3
2
3
3
3
3
3
2
2
2
3
3
3
3
2
3
3
2
2
3
1
3
3
3
3
2
3
3
1
4
3
3
3
2
2
2
2
0
3
1
3
4
1
2
2
...

result:

ok 4900 lines

Test #52:

score: 0
Accepted
time: 108ms
memory: 5140kb

input:

70 499800
24 63 10
67 32 1
55 47 1
52 50 8
48 32 5
25 56 7
22 45 3
37 3 1
30 32 5
2 8 1
6 37 3
40 30 9
53 16 5
35 65 9
54 51 7
29 54 1
35 55 1
12 44 2
26 51 1
30 47 8
24 7 4
10 60 2
32 16 2
62 40 9
63 5 10
61 1 6
9 25 10
7 21 4
37 42 10
47 11 10
10 54 7
19 20 5
64 16 9
41 19 3
17 52 10
7 30 3
48 33 ...

output:

0
2
2
3
2
2
2
3
3
3
1
2
3
3
3
2
4
2
2
3
4
3
2
3
4
2
4
2
2
1
4
4
3
3
2
3
3
3
3
2
2
3
2
2
2
2
3
3
2
1
2
3
2
3
3
3
3
2
1
2
2
3
2
1
4
2
3
3
2
3
3
0
1
4
2
1
2
2
3
4
1
2
2
4
3
2
3
2
3
2
3
3
1
3
4
2
3
3
3
1
4
3
2
3
2
3
2
3
3
3
3
3
2
2
2
4
3
3
3
2
5
3
2
2
3
1
3
3
3
3
2
3
3
1
4
3
3
5
2
2
2
2
0
3
1
4
4
1
2
2
...

result:

ok 4900 lines

Test #53:

score: 0
Accepted
time: 95ms
memory: 5276kb

input:

70 499800
24 63 10
67 32 1
55 47 1
52 50 8
48 32 5
25 56 7
22 45 3
37 3 1
30 32 5
2 8 1
6 37 3
40 30 9
53 16 5
35 65 9
54 51 7
29 54 1
35 55 1
12 44 2
26 51 1
30 47 8
24 7 4
10 60 2
32 16 2
62 40 9
63 5 10
61 1 6
9 25 10
7 21 4
37 42 10
47 11 10
10 54 7
19 20 5
64 16 9
41 19 3
17 52 10
7 30 3
48 33 ...

output:

0
2
2
3
2
2
2
3
3
3
1
2
3
3
3
2
3
2
2
3
3
3
2
3
3
2
3
2
2
1
3
3
3
3
2
3
3
3
3
2
2
3
2
2
2
2
3
3
2
1
2
3
2
3
3
3
3
2
1
2
2
3
2
1
4
2
3
3
2
3
3
0
1
4
2
1
2
2
3
3
1
2
2
3
3
2
3
2
3
2
3
3
1
3
3
2
3
3
3
1
3
3
2
3
2
3
2
3
3
3
3
3
2
2
2
3
3
3
3
2
3
3
2
2
3
1
3
3
3
3
2
3
3
1
4
3
3
3
2
2
2
2
0
3
1
3
4
1
2
2
...

result:

ok 4900 lines

Test #54:

score: 0
Accepted
time: 108ms
memory: 5260kb

input:

70 499800
67 49 23649
66 11 27826
35 42 13406
58 51 71998
30 29 77915
11 34 88028
15 46 15596
47 21 39557
52 36 35710
37 1 45977
14 69 25884
55 37 80514
49 23 46342
5 7 60430
20 53 82678
56 42 93575
69 69 25290
54 58 43929
60 33 66675
56 15 71306
34 66 89848
47 50 20904
16 42 56290
43 47 33933
25 36...

output:

0
14004
22090
22123
24083
25393
26714
31390
26389
25429
28488
23267
10207
17249
23847
21035
27167
22453
26296
23426
29674
17839
31669
31573
23130
28044
23493
28165
32205
20890
24212
20430
11459
26106
23212
27006
28223
24560
24247
11016
24796
24684
27524
25979
31698
24157
21855
23610
29900
12824
2335...

result:

ok 4900 lines

Test #55:

score: 0
Accepted
time: 100ms
memory: 5276kb

input:

70 499800
67 49 23649
66 11 27826
35 42 13406
58 51 71998
30 29 77915
11 34 88028
15 46 15596
47 21 39557
52 36 35710
37 1 45977
14 69 25884
55 37 80514
49 23 46342
5 7 60430
20 53 82678
56 42 93575
69 69 25290
54 58 43929
60 33 66675
56 15 71306
34 66 89848
47 50 20904
16 42 56290
43 47 33933
25 36...

output:

0
14004
22090
22123
24083
25393
26714
31390
26389
25429
28488
23267
10207
17249
23847
21035
27167
22453
26296
23426
29674
17839
31669
31573
23130
28044
23493
28165
32205
20890
24212
20430
11459
26106
23212
27006
28223
24560
24247
11016
24796
24684
27524
25979
31698
24157
21855
23610
29900
12824
2335...

result:

ok 4900 lines

Test #56:

score: 0
Accepted
time: 112ms
memory: 5244kb

input:

70 499800
67 49 23649
66 11 27826
35 42 13406
58 51 71998
30 29 77915
11 34 88028
15 46 15596
47 21 39557
52 36 35710
37 1 45977
14 69 25884
55 37 80514
49 23 46342
5 7 60430
20 53 82678
56 42 93575
69 69 25290
54 58 43929
60 33 66675
56 15 71306
34 66 89848
47 50 20904
16 42 56290
43 47 33933
25 36...

output:

0
14004
22090
22123
24083
25393
26714
31390
26389
25429
28488
23267
10207
17249
23847
21035
27167
22453
26296
23426
29674
17839
31669
31573
23130
28044
23493
28165
32205
20890
24212
20430
11459
26106
23212
27006
28223
24560
24247
11016
24796
24684
27524
25979
31698
24157
21855
23610
29900
12824
2335...

result:

ok 4900 lines

Test #57:

score: 0
Accepted
time: 95ms
memory: 5232kb

input:

70 499800
67 49 23649
66 11 27826
35 42 13406
58 51 71998
30 29 77915
11 34 88028
15 46 15596
47 21 39557
52 36 35710
37 1 45977
14 69 25884
55 37 80514
49 23 46342
5 7 60430
20 53 82678
56 42 93575
69 69 25290
54 58 43929
60 33 66675
56 15 71306
34 66 89848
47 50 20904
16 42 56290
43 47 33933
25 36...

output:

0
14004
22090
22123
24083
25393
26714
31390
26389
25429
28488
23267
10207
17249
23847
21035
27167
22453
26296
23426
29674
17839
31669
31573
23130
28044
23493
28165
32205
20890
24212
20430
11459
26106
23212
27006
28223
24560
24247
11016
24796
24684
27524
25979
31698
24157
21855
23610
29900
12824
2335...

result:

ok 4900 lines

Test #58:

score: 0
Accepted
time: 83ms
memory: 5304kb

input:

70 514500
64 62 64
49 32 50
23 17 38
4 29 18
25 64 40
43 19 65
57 14 9
25 24 73
37 23 44
36 42 94
1 50 4
46 63 13
21 6 73
46 45 89
42 38 82
70 10 13
40 55 91
30 32 69
58 53 5
21 19 91
44 39 71
8 10 8
36 70 95
65 68 78
70 11 38
6 67 56
57 10 44
43 24 84
67 6 88
60 47 64
58 68 58
19 34 28
49 36 37
66 ...

output:

0
2
2
4
3
6
3
3
4
4
2
3
2
3
3
3
3
5
4
3
2
3
7
3
1
3
3
4
3
1
2
2
1
5
3
2
5
2
7
3
3
6
4
2
3
4
3
3
2
2
1
2
2
2
3
4
4
5
1
2
2
3
3
3
3
4
3
4
3
3
7
0
3
2
5
4
3
2
3
6
2
1
3
1
5
1
6
5
4
4
2
2
3
4
2
1
2
5
6
3
8
3
3
3
2
3
4
3
6
2
5
2
5
4
3
4
2
5
3
2
7
2
3
2
5
5
8
7
5
6
3
1
1
2
5
2
4
5
3
2
3
2
0
7
3
2
5
2
2
3
...

result:

ok 4900 lines

Test #59:

score: 0
Accepted
time: 87ms
memory: 5276kb

input:

70 514500
64 62 64
49 32 50
23 17 38
4 29 18
25 64 40
43 19 65
57 14 9
25 24 73
37 23 44
36 42 94
1 50 4
46 63 13
21 6 73
46 45 89
42 38 82
70 10 13
40 55 91
30 32 69
58 53 5
21 19 91
44 39 71
8 10 8
36 70 95
65 68 78
70 11 38
6 67 56
57 10 44
43 24 84
67 6 88
60 47 64
58 68 58
19 34 28
49 36 37
66 ...

output:

0
2
2
4
3
3
3
3
3
4
2
3
2
3
3
3
3
3
3
3
2
3
4
3
1
3
3
4
3
1
2
2
1
3
3
2
4
2
4
3
3
4
4
2
3
3
3
3
2
2
1
2
2
2
3
3
3
3
1
2
2
3
3
3
3
3
3
4
3
3
5
0
3
2
4
4
3
2
3
4
2
1
3
1
4
1
4
3
4
4
2
2
3
3
2
1
2
4
4
3
3
3
3
3
2
3
3
3
3
2
3
2
3
3
3
3
2
4
3
2
4
2
3
2
3
4
4
4
3
4
3
1
1
2
3
2
3
4
3
2
3
2
0
3
3
2
5
2
2
3
...

result:

ok 4900 lines

Test #60:

score: 0
Accepted
time: 114ms
memory: 5144kb

input:

70 514500
64 62 64
49 32 50
23 17 38
4 29 18
25 64 40
43 19 65
57 14 9
25 24 73
37 23 44
36 42 94
1 50 4
46 63 13
21 6 73
46 45 89
42 38 82
70 10 13
40 55 91
30 32 69
58 53 5
21 19 91
44 39 71
8 10 8
36 70 95
65 68 78
70 11 38
6 67 56
57 10 44
43 24 84
67 6 88
60 47 64
58 68 58
19 34 28
49 36 37
66 ...

output:

0
2
2
4
3
3
3
3
3
4
2
3
2
3
3
3
3
3
3
3
2
3
4
3
1
3
3
4
3
1
2
2
1
3
3
2
4
2
4
3
3
4
4
2
3
3
3
3
2
2
1
2
2
2
3
3
3
3
1
2
2
3
3
3
3
3
3
4
3
3
5
0
3
2
4
4
3
2
3
4
2
1
3
1
4
1
4
3
4
4
2
2
3
3
2
1
2
4
4
3
3
3
3
3
2
3
3
3
3
2
3
2
3
3
3
3
2
4
3
2
4
2
3
2
3
4
4
4
3
4
3
1
1
2
3
2
3
4
3
2
3
2
0
3
3
2
5
2
2
3
...

result:

ok 4900 lines

Test #61:

score: 0
Accepted
time: 112ms
memory: 5340kb

input:

70 514500
64 62 64
49 32 50
23 17 38
4 29 18
25 64 40
43 19 65
57 14 9
25 24 73
37 23 44
36 42 94
1 50 4
46 63 13
21 6 73
46 45 89
42 38 82
70 10 13
40 55 91
30 32 69
58 53 5
21 19 91
44 39 71
8 10 8
36 70 95
65 68 78
70 11 38
6 67 56
57 10 44
43 24 84
67 6 88
60 47 64
58 68 58
19 34 28
49 36 37
66 ...

output:

0
2
2
4
3
3
3
3
3
4
2
3
2
3
3
3
3
3
3
3
2
3
4
3
1
3
3
4
3
1
2
2
1
3
3
2
4
2
4
3
3
4
4
2
3
3
3
3
2
2
1
2
2
2
3
3
3
3
1
2
2
3
3
3
3
3
3
4
3
3
5
0
3
2
4
4
3
2
3
4
2
1
3
1
4
1
4
3
4
4
2
2
3
3
2
1
2
4
4
3
3
3
3
3
2
3
3
3
3
2
3
2
3
3
3
3
2
4
3
2
4
2
3
2
3
4
4
4
3
4
3
1
1
2
3
2
3
4
3
2
3
2
0
3
3
2
5
2
2
3
...

result:

ok 4900 lines

Test #62:

score: 0
Accepted
time: 100ms
memory: 5304kb

input:

70 490069
53 41 10
41 65 5
65 31 2
31 52 10
52 28 5
28 29 8
29 21 6
21 1 7
1 48 4
48 47 2
47 33 4
33 40 6
40 13 5
13 46 1
46 32 4
32 39 9
39 16 7
16 6 6
6 63 6
63 44 3
44 17 2
17 34 2
34 7 1
7 12 3
12 19 8
19 50 3
50 62 1
62 3 9
3 14 5
14 25 6
25 38 8
38 69 3
69 36 8
36 58 6
58 30 7
30 42 10
42 27 1...

output:

0
1849
1841
1842
3020
2648
1221
1592
3344
2647
2986
4189
3067
2303
3263
1904
3244
3576
2155
1840
7
1107
1058
1752
2238
2420
1161
21
13
1989
2323
2725
4201
3417
3253
1716
1845
2230
2926
1919
1268
2631
3091
2105
2689
3199
2261
2671
2629
1851
2810
2313
1278
2806
3192
1232
3103
1996
2693
1097
2638
1850
...

result:

ok 4900 lines

Test #63:

score: 0
Accepted
time: 110ms
memory: 5144kb

input:

70 490069
53 41 10
41 65 5
65 31 2
31 52 10
52 28 5
28 29 8
29 21 6
21 1 7
1 48 4
48 47 2
47 33 4
33 40 6
40 13 5
13 46 1
46 32 4
32 39 9
39 16 7
16 6 6
6 63 6
63 44 3
44 17 2
17 34 2
34 7 1
7 12 3
12 19 8
19 50 3
50 62 1
62 3 9
3 14 5
14 25 6
25 38 8
38 69 3
69 36 8
36 58 6
58 30 7
30 42 10
42 27 1...

output:

0
1175
1163
1842
1111
1139
1187
1104
1111
1107
1109
1184
1166
1158
1093
1145
1128
1087
1176
1069
7
1107
1058
1075
1152
1096
1109
21
13
1120
36
1161
1177
1222
1103
1133
1171
1144
1152
1171
43
1110
1087
1130
1181
1165
1179
1181
1089
1173
1086
26
53
1083
1109
1064
1094
1127
1186
1097
1098
1172
1133
111...

result:

ok 4900 lines

Test #64:

score: 0
Accepted
time: 127ms
memory: 5412kb

input:

70 490069
53 41 10
41 65 5
65 31 2
31 52 10
52 28 5
28 29 8
29 21 6
21 1 7
1 48 4
48 47 2
47 33 4
33 40 6
40 13 5
13 46 1
46 32 4
32 39 9
39 16 7
16 6 6
6 63 6
63 44 3
44 17 2
17 34 2
34 7 1
7 12 3
12 19 8
19 50 3
50 62 1
62 3 9
3 14 5
14 25 6
25 38 8
38 69 3
69 36 8
36 58 6
58 30 7
30 42 10
42 27 1...

output:

0
1175
1163
1842
1111
1139
1187
1104
1111
1107
1109
1184
1166
1158
1093
1145
1128
1087
1176
1069
7
1107
1058
1075
1152
1096
1109
21
13
1120
36
1161
1177
1188
1103
1133
1171
1144
1152
1171
43
1110
1087
1130
1181
1165
1179
1181
1089
1173
1086
26
53
1083
1109
1064
1094
1127
1186
1097
1098
1172
1133
111...

result:

ok 4900 lines

Test #65:

score: 0
Accepted
time: 94ms
memory: 5412kb

input:

70 490069
53 41 10
41 65 5
65 31 2
31 52 10
52 28 5
28 29 8
29 21 6
21 1 7
1 48 4
48 47 2
47 33 4
33 40 6
40 13 5
13 46 1
46 32 4
32 39 9
39 16 7
16 6 6
6 63 6
63 44 3
44 17 2
17 34 2
34 7 1
7 12 3
12 19 8
19 50 3
50 62 1
62 3 9
3 14 5
14 25 6
25 38 8
38 69 3
69 36 8
36 58 6
58 30 7
30 42 10
42 27 1...

output:

0
1175
1163
1842
1111
1139
1187
1104
1111
1107
1109
1184
1166
1158
1093
1145
1128
1087
1176
1069
7
1107
1058
1075
1152
1096
1109
21
13
1120
36
1161
1177
1188
1103
1133
1171
1144
1152
1171
43
1110
1087
1130
1181
1165
1179
1181
1089
1173
1086
26
53
1083
1109
1064
1094
1127
1186
1097
1098
1172
1133
111...

result:

ok 4900 lines

Extra Test:

score: 0
Extra Test Passed