QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#401457#8409. Żelki [B]ucup-team05210 ✓165ms4632kbC++231.4kb2024-04-28 18:50:592024-04-28 18:50:59

Judging History

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

  • [2024-04-28 18:50:59]
  • 评测
  • 测评结果:10
  • 用时:165ms
  • 内存:4632kb
  • [2024-04-28 18:50:59]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define mod 998244353
#define int long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
#define N 7005
int n,k,m,col[N],w[N],s[N];
inline int add(int x,int y) {return x+y>=m?x+y-m:x+y;}
vector<int> ids[N];
int f[N],g[N],dis[N],vis[N];
signed main()
{
	cin>>n>>k>>m;
	for(int i=1;i<=n;i++)
	{
		col[i]=read(),w[i]=read()%m,s[i]=read();
		ids[col[i]].push_back(i);
	}
	memset(f,0x3f,sizeof(f)); f[0]=0;
	for(int i=1;i<=k;i++)
	{
		memset(g,0x3f,sizeof(g));
		for(int u:ids[i])
		{
			for(int j=0;j<m;j++) g[add(j,w[u])]=min(g[add(j,w[u])],f[j]+s[u]);
		}
		memcpy(f,g,sizeof(f));
	}
	// for(int i=0;i<m;i++) printf("%lld%c",f[i]," \n"[i==m-1]);
	memset(dis,0x3f,sizeof(dis)); dis[0]=0;
	for(int T=0;T<m;T++)
	{
		int mn=INF,mnid=-1;
		for(int j=0;j<m;j++) if(!vis[j]&&dis[j]<mn) mn=dis[j],mnid=j;
		if(mnid==-1) break;
		vis[mnid]=1;
		for(int j=0;j<m;j++) dis[add(mnid,j)]=min(dis[add(mnid,j)],dis[mnid]+f[j]);
	}
	for(int i=0;i<m;i++)
	{
		if(dis[i]==INF) printf("-1\n");
		else printf("%lld\n",dis[i]);
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 1
Accepted

Test #1:

score: 1
Accepted
time: 1ms
memory: 4052kb

input:

1 1 1
1 1 86

output:

0

result:

ok single line: '0'

Test #2:

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

input:

1 1 30
1 3 66

output:

0
-1
-1
66
-1
-1
132
-1
-1
198
-1
-1
264
-1
-1
330
-1
-1
396
-1
-1
462
-1
-1
528
-1
-1
594
-1
-1

result:

ok 30 lines

Test #3:

score: 0
Accepted
time: 1ms
memory: 4004kb

input:

1 2 30
1 22 21

output:

0
-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

result:

ok 30 lines

Test #4:

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

input:

30 1 27
1 19 45
1 11 8
1 25 94
1 25 39
1 27 7
1 16 41
1 15 9
1 9 34
1 2 84
1 8 45
1 7 36
1 21 13
1 3 89
1 12 9
1 18 72
1 3 61
1 14 82
1 22 71
1 13 59
1 27 83
1 1 77
1 14 20
1 18 37
1 25 49
1 1 39
1 7 76
1 26 93
1 12 24
1 4 53
1 24 58

output:

0
38
29
18
38
21
22
25
26
22
25
8
9
37
20
9
29
30
27
34
30
13
16
17
18
28
17

result:

ok 27 lines

Test #5:

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

input:

30 2 29
1 24 7
1 22 93
1 23 55
2 5 39
2 16 88
2 10 13
2 21 81
1 29 93
2 24 52
2 9 77
2 4 53
1 12 41
2 25 13
1 22 33
1 20 26
2 23 46
1 19 92
2 5 19
2 4 54
2 16 71
2 21 74
1 15 26
2 16 1
2 29 77
2 7 52
2 17 25
2 20 56
1 22 38
2 12 73
1 17 24

output:

0
39
27
46
24
20
51
27
48
34
40
8
32
35
54
32
28
52
35
56
20
48
16
40
43
39
40
36
42

result:

ok 29 lines

Test #6:

score: 0
Accepted
time: 1ms
memory: 3984kb

input:

30 5 30
2 18 72
5 12 65
4 12 14
3 3 38
2 3 69
1 13 76
2 26 99
5 23 1
4 7 48
4 25 100
1 20 17
1 5 20
2 13 53
3 15 54
3 18 24
3 23 42
5 22 60
1 6 6
5 7 39
3 20 81
3 3 15
2 8 19
5 21 80
3 30 38
1 28 2
2 27 83
4 29 45
3 21 89
4 28 84
2 12 94

output:

0
82
98
89
78
107
66
64
100
85
128
74
82
98
51
120
91
89
92
78
104
69
55
97
94
112
90
89
89
60

result:

ok 30 lines

Test #7:

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

input:

30 10 28
6 4 90
4 13 85
9 28 27
3 3 87
10 8 60
9 28 8
4 27 59
5 11 29
4 19 97
7 15 21
8 24 54
6 25 2
1 23 50
5 16 41
10 17 55
8 1 56
9 28 52
4 11 69
4 1 62
7 16 72
6 27 94
5 9 92
1 5 65
6 20 63
7 18 29
1 8 82
7 20 72
7 21 72
5 28 96
2 28 31

output:

0
403
428
406
411
396
414
399
404
423
398
418
401
406
426
409
421
406
418
422
413
433
408
421
401
416
404
409

result:

ok 28 lines

Test #8:

score: 0
Accepted
time: 1ms
memory: 3992kb

input:

30 30 30
26 11 86
8 15 65
16 22 85
12 29 68
25 25 21
4 1 41
13 23 15
14 14 7
19 10 37
6 8 12
29 2 45
21 27 42
2 29 56
24 8 23
5 10 29
9 28 71
15 18 17
22 26 39
30 14 22
23 24 69
11 18 53
20 6 88
10 18 76
27 18 56
17 4 23
18 4 51
1 3 50
3 13 13
28 3 68
7 5 45

output:

0
-1
2746
-1
5492
-1
8238
-1
10984
-1
13730
-1
16476
-1
19222
-1
1373
-1
4119
-1
6865
-1
9611
-1
12357
-1
15103
-1
17849
-1

result:

ok 30 lines

Subtask #2:

score: 1
Accepted

Test #9:

score: 1
Accepted
time: 1ms
memory: 3940kb

input:

100 1 99
1 19 412373968
1 13 284266953
1 52 472412087
1 28 44413688
1 10 342928235
1 62 280085991
1 59 142379537
1 85 775288653
1 43 920354596
1 57 608163801
1 78 258809522
1 39 341362355
1 72 608037511
1 94 778618930
1 3 508479027
1 16 625019211
1 40 57256617
1 16 120369844
1 63 248306350
1 36 2934...

output:

0
43534561
80130477
56524661
54583165
30977349
73640993
5430037
48964598
85560514
61954698
60013202
36407386
79071030
10860074
54394635
90990551
67384735
65443239
41837423
78807705
16290111
53260393
96420588
27713081
70873276
47267460
83863376
21720148
58316064
101354074
32768752
76303313
52697497
8...

result:

ok 99 lines

Test #10:

score: 0
Accepted
time: 1ms
memory: 3944kb

input:

96 2 98
2 16 528477808
2 19 50688868
1 48 38469614
1 67 552816707
1 78 97205830
1 58 985388179
2 67 765348605
2 91 470262217
2 12 227653636
1 45 114758403
2 55 985357836
1 32 232832897
2 56 54120363
1 36 462478422
1 34 538429301
1 1 12634777
1 94 825719331
2 4 158004730
2 78 226933328
1 60 343433875...

output:

0
199935353
111315352
137864010
146116584
117022045
92589977
165300985
203905329
194718740
208387967
209612022
185179954
133276581
199534682
244591933
133510280
123245893
175533046
211218343
63323645
217751266
174638997
201187655
193769850
180345690
155913622
164166196
186194412
212534653
256522474
...

result:

ok 98 lines

Test #11:

score: 0
Accepted
time: 1ms
memory: 3996kb

input:

100 4 100
4 77 372857660
2 61 126703565
3 93 892510081
3 12 975633927
2 97 700134450
1 94 384055349
3 39 807509961
3 25 414744807
4 54 792910019
1 62 33900472
1 37 626638611
4 99 123254417
2 8 669749888
1 69 481969033
3 55 158785811
2 4 446582117
4 23 906996919
3 65 32665231
2 5 598656331
1 2 719098...

output:

0
342709151
324280868
273038137
246150806
247619282
337456832
305577906
333923209
338874405
393236413
353312230
450209519
243030089
240402470
305879603
331708496
233912145
328174873
296761659
340718798
234872883
328841549
253633168
341073569
372321425
361381318
244515224
320299231
333501986
38314874...

result:

ok 100 lines

Test #12:

score: 0
Accepted
time: 1ms
memory: 3996kb

input:

100 10 100
4 66 224941057
10 5 603689164
1 58 572036935
1 59 808714142
5 79 56536143
10 92 315244046
2 38 356423852
6 31 5402122
2 79 729256443
6 22 889167622
6 1 57135023
10 76 924947768
6 70 686036280
6 25 734478225
1 96 675578922
9 55 184873932
8 33 640349996
3 22 882406036
9 81 659750962
5 54 86...

output:

0
934911814
905794749
986688866
982086322
928790558
938718733
993234049
977196168
952180183
959121047
963272830
957968441
966208565
886756314
941271630
948212494
909752123
964267439
971208303
968470039
1022985355
942073250
996588566
975015222
965069059
932694491
939635355
961119887
955690300
9119601...

result:

ok 100 lines

Test #13:

score: 0
Accepted
time: 1ms
memory: 4060kb

input:

99 99 100
83 27 671621728
73 86 196316830
74 87 654341769
27 21 549269697
52 26 147445016
2 78 336563381
35 73 676993312
96 33 469581601
62 41 222760364
30 42 111090502
25 56 745825495
77 73 849014034
64 47 125646735
66 12 193529871
53 69 340441158
16 19 696788487
57 12 700624609
36 95 65028226
28 8...

output:

0
360552466498
721104932996
1081657399494
1442209865992
1802762332490
2163314798988
2523867265486
2884419731984
3244972198482
3605524664980
3966077131478
4326629597976
4687182064474
5047734530972
257537476070
618089942568
978642409066
1339194875564
1699747342062
2060299808560
2420852275058
278140474...

result:

ok 100 lines

Test #14:

score: 0
Accepted
time: 1ms
memory: 4000kb

input:

99 50 100
15 70 118646405
5 99 839524586
16 60 611953736
9 8 407060116
50 81 518269702
11 12 225705473
22 19 269131807
19 35 30211628
33 30 737633070
5 51 267343196
43 93 546320914
43 45 384280758
38 32 330347363
7 33 185047148
41 46 335640323
11 76 551002108
49 29 704897482
27 19 583892271
44 81 62...

output:

0
17375796952
17490005889
17361654526
17487590727
17308368561
17422577498
17416284559
17530493496
17454224675
17412530969
17410193168
17398388543
17455286797
17345102578
17459311515
17453018576
17397957820
17458354217
17442708538
17446927185
17389422573
17434013709
17407987899
17517027254
1724772568...

result:

ok 100 lines

Test #15:

score: 0
Accepted
time: 1ms
memory: 3940kb

input:

100 25 100
20 72 225073029
22 11 635625058
21 18 414439767
21 33 488092246
19 28 646441481
1 40 251036557
20 44 694042567
4 51 118998249
25 75 435481794
20 66 374124084
11 54 826252649
18 19 924460708
21 33 204774899
8 11 818849046
14 92 305730481
10 91 955688679
3 37 219527026
7 42 739793375
21 32 ...

output:

0
5370740704
5359926765
5458347150
5376359228
5340456537
5350380361
5491898172
5476851715
5435079440
5450872848
5418644865
5376438516
5438981699
5403079008
5409098461
5366892112
5321598440
5393532604
5415713989
5431507397
5312052036
5447939860
5406167585
5421960993
5389733010
5451453514
5464976341
5...

result:

ok 100 lines

Test #16:

score: 0
Accepted
time: 1ms
memory: 3980kb

input:

95 10 100
5 68 461056378
6 64 234735938
10 84 386695627
1 98 13076206
3 21 890128022
10 8 245383690
5 21 233187723
2 90 465741490
2 14 961406526
10 34 595657650
6 9 682981504
9 44 251135858
1 10 730471126
10 89 830042191
8 6 347900132
5 9 942746715
2 56 977513975
7 1 763872817
4 93 642503455
6 54 64...

output:

0
1046441323
1161122125
1116679658
1109083144
1092086893
1047644426
1160372708
1152776194
1168419867
1091337476
1133105936
1136086353
1153979297
1074647635
1176798986
1156678914
1037110527
1149838809
1127162483
1156621890
1080803577
1146268267
1127105459
1143445398
1077233035
1082006680
1146145015
1...

result:

ok 100 lines

Test #17:

score: 0
Accepted
time: 1ms
memory: 4008kb

input:

100 100 100
71 15 857836581
62 51 925258990
56 95 373964709
17 41 785056273
24 94 365809672
9 97 869202319
29 71 598566721
49 78 839709023
70 7 710156812
28 64 52867760
84 75 624198765
67 46 309288741
54 26 255485019
50 46 964553515
88 1 964156062
13 54 421760317
78 41 775892703
46 23 143877470
97 5...

output:

0
-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
-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
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1

result:

ok 100 lines

Test #18:

score: 0
Accepted
time: 1ms
memory: 3984kb

input:

100 100 100
13 66 776045893
47 26 39219964
90 97 117967827
69 61 77977555
35 43 444931229
92 51 501672426
79 29 108989970
75 18 166559209
39 97 401419626
26 4 618690510
84 1 791790875
49 42 447565540
72 33 418727774
44 30 824217068
50 52 877262116
7 28 25904179
78 14 81649849
31 2 941360976
81 48 26...

output:

0
-1
-1
-1
440661198861
-1
-1
-1
881322397722
-1
-1
-1
97924710858
-1
-1
-1
538585909719
-1
-1
-1
979247108580
-1
-1
-1
195849421716
-1
-1
-1
636510620577
-1
-1
-1
1077171819438
-1
-1
-1
293774132574
-1
-1
-1
734435331435
-1
-1
-1
1175096530296
-1
-1
-1
391698843432
-1
-1
-1
832360042293
-1
-1
-1
48...

result:

ok 100 lines

Test #19:

score: 0
Accepted
time: 1ms
memory: 4060kb

input:

100 99 100
52 100 1000000000
85 100 1000000000
22 100 1000000000
76 100 1000000000
18 100 1000000000
51 100 1000000000
44 100 1000000000
67 100 1000000000
37 100 1000000000
33 100 1000000000
50 100 1000000000
23 100 1000000000
43 100 1000000000
27 100 1000000000
87 100 1000000000
78 100 1000000000
4...

output:

0
99000000000
198000000000
297000000000
396000000000
495000000000
594000000000
693000000000
792000000000
891000000000
990000000000
1089000000000
1188000000000
1287000000000
1386000000000
1485000000000
1584000000000
1683000000000
1782000000000
1881000000000
1980000000000
2079000000000
2178000000000
2...

result:

ok 100 lines

Subtask #3:

score: 1
Accepted

Test #20:

score: 1
Accepted
time: 1ms
memory: 3940kb

input:

200 1 199
1 128 824600560
1 127 112219532
1 12 143699094
1 103 566311267
1 167 38420489
1 96 134526506
1 37 27018425
1 131 732136452
1 176 57654948
1 33 311505313
1 109 617932628
1 35 422737013
1 173 193760705
1 47 144337121
1 82 400386694
1 161 472191910
1 173 933530930
1 138 529839119
1 8 85319867...

output:

0
94105051
86834184
83286596
83992424
64425248
95108029
88527013
76044436
92398081
70504113
74253678
102521055
75571998
68301131
19770668
63502928
88167636
58074389
54526801
63049087
55778220
84313056
95815104
108414821
90274781
94024346
85476578
73761260
88071799
39541336
83273596
34743133
62795421...

result:

ok 199 lines

Test #21:

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

input:

185 2 199
2 61 779978111
2 87 89237963
1 29 774292566
2 146 362151646
2 12 224807056
2 177 89670386
2 102 704237509
2 121 840078605
1 48 199389398
1 53 692916368
2 48 226021317
2 175 566793491
2 84 760984769
2 51 725993190
1 93 506215376
1 142 270136071
1 153 752044416
2 44 751381622
1 7 289817919
1...

output:

0
112057099
92657044
92909245
135820253
118057761
131664854
62770964
108837476
92425903
113573957
101778774
78699195
101162280
73411915
102462349
121892211
98812632
112419725
141470159
89592347
80216053
143710624
113355501
59454066
132817887
133070088
83217220
114457164
91109205
102931807
122225030
...

result:

ok 199 lines

Test #22:

score: 0
Accepted
time: 1ms
memory: 3996kb

input:

200 4 200
3 189 264712587
3 11 274823209
3 50 246498692
2 40 566479120
2 98 552305096
4 152 173937849
4 175 660108258
2 10 202099238
2 43 272663093
2 26 168027847
3 174 940045932
2 200 191689262
2 34 504571381
2 92 251382192
2 62 142896335
2 51 56292824
1 42 296118115
1 50 193636582
3 115 190352673
...

output:

0
151202918
191100452
192531191
191490832
231388366
148958269
162582592
127145719
167043253
208671236
150255750
194861908
173773146
138525393
215326595
181851976
207748670
126198551
184951257
101101061
140998595
146984994
186882528
168533813
196330931
160894058
77043862
116941396
184004089
227920569...

result:

ok 200 lines

Test #23:

score: 0
Accepted
time: 1ms
memory: 4124kb

input:

197 14 200
1 139 903500184
13 117 843571371
5 147 525525415
13 186 145735984
3 153 671751102
4 128 809408750
13 121 538236572
14 19 490431336
11 171 322604832
14 162 66727787
5 13 904226443
9 72 9318243
13 142 78722642
5 81 74159618
1 47 71499182
9 172 881903336
4 9 959166826
9 151 389156998
11 79 5...

output:

0
976025481
1007427579
916638802
944270675
985757221
954021669
981653542
952357541
979989414
1033472514
983009262
956534863
984166736
1020392129
1014630814
1030612260
992253602
928157959
1013277078
997276378
965540826
991606720
963876698
1024614194
1044991671
989609138
968054020
1011591991
102026085...

result:

ok 200 lines

Test #24:

score: 0
Accepted
time: 1ms
memory: 3932kb

input:

200 200 199
101 89 741703166
118 94 331184833
196 11 425928973
88 170 49272520
87 162 668193616
75 84 65791239
85 133 525147749
195 177 184628308
117 171 571081188
136 28 719992964
198 66 331140643
127 85 946299385
115 11 168188417
89 44 159069530
8 187 62258195
122 154 604962971
182 44 666082704
17...

output:

0
5164546539680
10329093079360
15493639619040
1971917769696
7136464309376
12301010849056
17465557388736
3943835539392
9108382079072
14272928618752
751206769408
5915753309088
11080299848768
16244846388448
2723124539104
7887671078784
13052217618464
18216764158144
4695042308800
9859588848480
1502413538...

result:

ok 199 lines

Test #25:

score: 0
Accepted
time: 1ms
memory: 3948kb

input:

200 100 200
71 66 824239052
11 116 621379129
93 163 784817462
70 116 111823697
21 186 386606830
96 131 364374789
10 174 704388933
70 12 722011907
34 36 169975705
79 92 26336464
82 37 318738666
92 82 573004597
16 121 725257170
4 41 6595792
83 32 449915011
6 174 593473377
73 27 851393114
64 111 801045...

output:

0
31745028255
31801525271
31780254827
31732450404
31702599389
31806686259
31723854033
31751366210
31776645881
31772620854
31745703354
31790178817
31787345851
31807250458
31801168902
31819533578
31789682563
31769004595
31758740036
31790850567
31779994680
31659543521
31812588096
31784595975
3177851441...

result:

ok 200 lines

Test #26:

score: 0
Accepted
time: 1ms
memory: 3996kb

input:

200 50 200
36 48 950555749
30 14 605927579
24 78 185896284
29 177 565809153
47 168 389652816
48 149 4480484
39 181 767352019
3 21 103020997
38 13 133666707
3 4 83809234
20 63 900317967
13 80 269579619
21 128 883942903
15 23 995653365
25 83 769207709
24 188 415068624
29 74 485936611
3 165 550221441
3...

output:

0
11354362764
11382016669
11359046824
11367566544
11342460093
11368258321
11367958972
11368982947
11382529188
11381162752
11356056301
11381854529
11405367521
11364032800
11396125396
11388024652
11382879334
11300000854
11399957573
11376121981
11401920209
11340069949
11342051912
11313597062
1135327372...

result:

ok 200 lines

Test #27:

score: 0
Accepted
time: 1ms
memory: 4124kb

input:

200 20 200
3 185 569162928
17 141 702915275
18 185 289089862
20 105 306559986
16 155 932183324
4 155 967033904
19 134 826470398
9 134 194159928
13 99 179709019
11 90 863678202
20 99 425867665
8 161 45278316
3 134 745466767
10 67 437009848
10 177 572603479
9 85 152169605
1 128 249328950
10 123 253617...

output:

0
2483392474
2475445432
2494396119
2468967268
2443705813
2502494249
2470335170
2446837456
2484756415
2487403645
2509138843
2476411423
2506414555
2474845808
2498448470
2466289391
2485381254
2437595879
2486276964
2493531592
2472365644
2451619174
2456773278
2462622819
2477251321
2475171514
2486347245
2...

result:

ok 200 lines

Test #28:

score: 0
Accepted
time: 1ms
memory: 3924kb

input:

200 200 200
82 100 672044514
22 18 554881423
127 97 80924273
174 50 592421473
167 132 280106003
69 95 250292635
34 166 333625093
142 80 777554476
88 181 954103798
102 200 859972861
180 136 739384952
69 59 405311639
153 160 942480531
100 84 193825309
157 125 14337454
181 39 274922369
46 14 880256108
...

output:

0
-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
-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
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-...

result:

ok 200 lines

Test #29:

score: 0
Accepted
time: 1ms
memory: 3952kb

input:

200 200 200
151 148 127046879
76 85 902463656
86 94 858306473
79 20 944919743
45 189 656481308
33 18 457466732
163 37 221198653
164 30 688052487
13 118 898279383
55 42 192683336
197 195 573727968
184 188 671473494
101 51 641160920
66 85 197587431
172 170 504526307
41 99 876309931
135 163 774712174
1...

output:

0
16374377006113
12657493882026
8940610757939
5223727633852
1506844509765
17881221515878
14164338391791
10447455267704
6730572143617
3013689019530
19388066025643
15671182901556
11954299777469
8237416653382
4520533529295
803650405208
17178027411321
13461144287234
9744261163147
6027378039060
231049491...

result:

ok 200 lines

Test #30:

score: 0
Accepted
time: 1ms
memory: 4016kb

input:

200 199 200
41 200 1000000000
3 200 1000000000
185 200 1000000000
175 200 1000000000
136 200 1000000000
93 200 1000000000
53 200 1000000000
7 200 1000000000
15 200 1000000000
108 200 1000000000
146 200 1000000000
32 200 1000000000
104 200 1000000000
39 200 1000000000
59 200 1000000000
83 200 1000000...

output:

0
199000000000
398000000000
597000000000
796000000000
995000000000
1194000000000
1393000000000
1592000000000
1791000000000
1990000000000
2189000000000
2388000000000
2587000000000
2786000000000
2985000000000
3184000000000
3383000000000
3582000000000
3781000000000
3980000000000
4179000000000
437800000...

result:

ok 200 lines

Subtask #4:

score: 1
Accepted

Test #31:

score: 1
Accepted
time: 1ms
memory: 3992kb

input:

365 1 400
1 342 968808428
1 181 124089566
1 66 6850211
1 292 427280984
1 49 331697176
1 123 185410872
1 209 955875078
1 18 646626477
1 282 14847576
1 189 6330278
1 55 779118437
1 10 170176095
1 214 714864949
1 105 332308718
1 75 889245317
1 383 122158247
1 125 383274010
1 171 138266504
1 98 59467589...

output:

0
5444675
4875884
9187257
4871604
4302813
6699364
4298533
8609906
4294253
3725462
6122013
3721182
8032555
3716902
3148111
7376702
3143831
7455204
3139551
2570760
6799351
2566480
8011155
2562200
6873573
7438084
1989129
7433804
3816889
6296222
6860733
1411778
6856453
3239538
5718871
6283382
834427
627...

result:

ok 400 lines

Test #32:

score: 0
Accepted
time: 1ms
memory: 4064kb

input:

400 2 399
2 323 48146386
1 194 158105521
1 293 724602885
1 172 293791355
1 191 47897263
1 84 281880376
2 47 142549530
1 218 251995940
2 149 898993678
1 135 511444741
2 102 994045419
1 82 680336208
2 235 109206141
2 342 837883405
2 166 629926917
2 361 611962208
1 122 270701866
1 104 280145501
1 4 481...

output:

0
47282338
43835273
49995437
36365336
38880644
43772530
43665316
43998322
49504792
32748314
35320232
42077093
35546024
47014867
34521425
40681589
36097865
29566796
34458682
41215543
45613163
40190944
43213281
42041064
35236315
39823196
46885062
40353993
36061836
42629436
43016488
25144834
31901695
5...

result:

ok 399 lines

Test #33:

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

input:

388 4 400
1 10 718201511
4 248 170454737
4 215 431559822
1 99 226264321
4 344 187626806
4 159 823781134
1 311 342689507
2 126 408900662
3 234 772522100
1 14 679768501
1 48 752289285
1 194 817804915
4 250 740210844
2 20 988005823
4 57 335079184
4 388 959520229
3 340 161432922
1 185 390004814
3 68 769...

output:

0
73550150
81314988
67306445
92715051
70597419
64401081
56045808
74249041
39326501
68732339
83455248
94552313
32271792
87777403
78930066
74692696
89317110
78653002
69956076
64583552
74525879
71598293
65704011
86161949
46182060
64543584
65503874
65537194
80500368
47629892
68278063
99782930
37148817
6...

result:

ok 400 lines

Test #34:

score: 0
Accepted
time: 1ms
memory: 4008kb

input:

372 20 400
10 53 923385820
12 117 275880886
9 143 978764309
15 125 287657192
16 30 240081375
2 301 445542659
5 203 867095291
16 306 454253412
10 24 367257786
6 273 300582475
14 106 28948267
6 110 549463963
12 238 316538364
5 312 113353786
6 137 945272725
5 212 146433833
16 212 135167598
2 122 204939...

output:

0
852384902
879402956
876770207
846997558
883371597
842639459
867542068
843883593
866628214
862154724
879542089
858595062
881339683
876734333
844517516
874439262
860010979
869971835
861546393
869007889
868114064
887641676
881310251
863249329
874254291
832394753
855139374
871065395
867491793
87674332...

result:

ok 400 lines

Test #35:

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

input:

400 400 398
347 20 367778928
265 5 89292067
298 106 47163123
383 230 148953887
210 117 237366000
293 187 659669282
309 148 9580581
143 133 749719770
386 310 821895167
227 102 307204204
303 3 345352410
396 238 354963547
239 54 231066647
6 248 33027394
50 182 330451936
192 327 154750695
275 72 1366599...

output:

0
-1
744475407208
-1
1488950814416
-1
2233426221624
-1
2977901628832
-1
3722377036040
-1
4466852443248
-1
5211327850456
-1
5955803257664
-1
6700278664872
-1
7444754072080
-1
8189229479288
-1
8933704886496
-1
9678180293704
-1
10422655700912
-1
11167131108120
-1
11911606515328
-1
12656081922536
-1
134...

result:

ok 398 lines

Test #36:

score: 0
Accepted
time: 1ms
memory: 4004kb

input:

400 200 400
162 138 177675371
171 195 33791038
134 7 824370267
104 310 766457190
74 16 423828758
58 108 546534679
26 365 730073468
25 27 986663598
44 301 691938495
113 18 960617842
36 124 370991771
182 250 944555362
167 49 540176179
125 138 599424051
113 121 881773619
185 157 814019590
168 354 71942...

output:

0
71032891213
71051191679
71037333765
71016316120
71042058911
71028739669
71005764037
71038543826
71031928434
71034099700
71039249313
71013607527
71034095805
71045993882
71020352096
71041549756
71035208726
71021057583
71053837372
71030861740
71034284406
71027407952
71047896230
71031974661
7098875761...

result:

ok 400 lines

Test #37:

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

input:

361 100 395
81 188 655795927
29 135 650272752
29 71 134766295
62 87 924903464
13 200 657144336
71 210 545745200
52 315 848040878
39 265 946898071
79 94 304270073
65 125 700678967
45 253 132904384
67 61 820263306
37 141 441916430
56 354 233664356
22 12 210231639
20 41 437516966
68 139 965948721
56 34...

output:

0
21054661385
21043989670
21066663184
21058725933
21054534785
21050643869
21043014594
21043533972
21061188984
21053559709
21054079087
21053893911
21057624257
21058143635
21064439026
21054889136
21024162100
21038761315
21064604205
21034707215
21049306430
21069498799
21038771763
21053370978
2107502273...

result:

ok 395 lines

Test #38:

score: 0
Accepted
time: 1ms
memory: 4004kb

input:

367 40 400
9 84 27965990
2 375 606074682
21 281 207899458
21 122 23837463
12 213 408016914
40 68 705825815
29 219 987466355
39 298 448113453
22 6 402765600
11 331 817591119
39 18 575517285
37 362 693855048
23 40 270088839
26 383 351546822
13 132 156101411
4 82 122107213
5 137 408848802
7 177 3343201...

output:

0
3451215152
3419168612
3435344718
3434491370
3443759195
3430765352
3444853915
3410013382
3397895465
3445667296
3411150349
3399032432
3421266346
3467039538
3464571060
3431561074
3430863927
3446978687
3446963840
3434845923
3435543943
3395875467
3435982890
3443732439
3421211052
3417482702
3426750527
3...

result:

ok 400 lines

Test #39:

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

input:

400 400 400
204 337 430950538
295 30 924273212
115 281 252469173
210 70 422772424
229 174 111998351
26 59 15851294
258 308 614279729
17 241 900313807
387 225 210887561
358 43 251458728
376 164 854976637
323 129 534964970
139 357 51427263
260 341 221950508
32 74 323223594
393 148 529275353
142 258 31...

output:

0
-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
-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
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-...

result:

ok 400 lines

Test #40:

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

input:

400 400 400
57 217 788669502
318 31 908003477
218 54 209319327
199 5 747766224
214 259 74993203
38 298 668189425
210 35 114948659
28 296 815290170
270 313 34312201
262 86 304218879
12 43 259814549
86 333 307836678
179 65 288426032
5 251 171975832
237 241 901304625
67 195 779826190
121 188 802699729
...

output:

0
-1
-1
-1
13889006387738
-1
-1
-1
8216031947676
-1
-1
-1
2543057507614
-1
-1
-1
16432063895352
-1
-1
-1
10759089455290
-1
-1
-1
5086115015228
-1
-1
-1
18975121402966
-1
-1
-1
13302146962904
-1
-1
-1
7629172522842
-1
-1
-1
1956198082780
-1
-1
-1
15845204470518
-1
-1
-1
10172230030456
-1
-1
-1
449925...

result:

ok 400 lines

Test #41:

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

input:

400 399 400
105 400 1000000000
63 400 1000000000
30 400 1000000000
172 400 1000000000
370 400 1000000000
314 400 1000000000
16 400 1000000000
84 400 1000000000
387 400 1000000000
229 400 1000000000
118 400 1000000000
332 400 1000000000
53 400 1000000000
362 400 1000000000
52 400 1000000000
108 400 1...

output:

0
399000000000
798000000000
1197000000000
1596000000000
1995000000000
2394000000000
2793000000000
3192000000000
3591000000000
3990000000000
4389000000000
4788000000000
5187000000000
5586000000000
5985000000000
6384000000000
6783000000000
7182000000000
7581000000000
7980000000000
8379000000000
877800...

result:

ok 400 lines

Test #42:

score: 0
Accepted
time: 1ms
memory: 3992kb

input:

392 50 400
1 361 6956669
14 146 636803262
12 123 326703668
39 142 154532241
19 56 376900863
24 61 214325952
37 16 731179945
13 271 538824843
31 254 590532119
18 72 225642922
39 182 10731411
39 282 685584288
28 137 287801234
2 300 879449183
10 396 214653309
25 180 25816261
48 120 74812627
47 177 9701...

output:

0
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
4920504258
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
4921773536
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
4922147596
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
4919293455
-1
-1
-1
-1
-1
-1
-1
-1
-1...

result:

ok 400 lines

Subtask #5:

score: 1
Accepted

Test #43:

score: 1
Accepted
time: 2ms
memory: 4152kb

input:

793 1 800
1 290 604453394
1 279 499450458
1 790 895978946
1 460 2056625
1 628 462950181
1 294 618469697
1 668 697631666
1 800 807220807
1 463 356851697
1 689 797183205
1 674 645113723
1 272 556623699
1 361 202898764
1 655 779193735
1 226 887691362
1 620 14523199
1 476 704320683
1 788 63689618
1 377 ...

output:

0
17677433
18502733
15890039
13277345
19505937
16893243
19667071
17054377
14441683
11828989
9216295
6603601
17450722
21668340
22155021
19880946
22234457
19621763
17009069
14396375
11865379
18432590
15819896
13207202
10594508
13805423
11192729
8580035
19316699
26225364
23612670
20999976
18468980
1585...

result:

ok 800 lines

Test #44:

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

input:

763 2 800
2 690 663912471
2 791 842536023
2 453 260259693
1 342 957454003
1 705 657121245
2 496 83129059
1 292 784279909
1 603 984202698
1 506 976761552
1 87 293820556
1 681 115698434
2 310 436350126
2 744 329237985
2 80 754203632
1 15 48809693
2 79 69482851
1 59 23629500
2 547 101696070
1 413 28581...

output:

0
10405711
15476827
16988981
10879803
14680082
16447173
16694463
2816619
9648577
16005321
19805600
13696422
14058649
15710803
11742416
5633238
12465196
18821940
14605977
10795667
14581197
10758756
14559035
8449857
15281815
13622317
10690764
12457855
13824063
13575375
17375654
11266476
12638657
97071...

result:

ok 800 lines

Test #45:

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

input:

757 4 795
1 681 25717267
4 426 934934513
1 603 489997815
2 411 400770490
3 551 299951382
1 635 758155469
1 318 38613531
4 268 182539640
2 479 166419982
2 585 687192225
2 45 513261754
4 132 794467524
3 611 91184165
3 49 122950535
4 216 552089397
2 246 461514753
4 498 682281294
4 255 700314575
2 525 8...

output:

0
52293408
46947083
57873980
36923415
55158392
33412314
46893853
43618244
53045464
50278035
54779732
35008998
58489220
47818040
52666804
35930335
38968920
45705112
43768560
49322122
50694142
54350480
48884102
53782325
43389900
46824960
46771174
63750391
52351746
63354186
49636158
57063818
42270872
3...

result:

ok 795 lines

Test #46:

score: 0
Accepted
time: 3ms
memory: 4036kb

input:

800 28 800
17 367 465017203
16 797 609236617
2 56 497548260
17 736 574777943
1 708 252856959
11 632 217815736
19 154 279130966
26 362 538526942
7 218 322637960
11 385 64421589
9 519 500543355
19 525 794918858
15 582 19662994
25 717 210889149
10 505 465485761
17 591 466681859
5 294 123732308
23 384 1...

output:

0
719897484
715122288
711210400
711173914
712431899
723360135
716633735
713480982
699791174
725508696
726314122
721133386
717998754
712498612
710432445
708799653
718352281
729958024
710342704
723812102
720659349
706969541
730322783
715671409
715624493
713195900
719676979
717610812
702861207
69727927...

result:

ok 800 lines

Test #47:

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

input:

800 800 796
177 517 556073547
378 356 316751046
298 558 458758543
445 169 291559544
175 573 135562970
432 267 551743806
165 541 114219907
724 767 303525514
648 298 718815826
507 218 804885341
292 185 828330147
535 132 998627947
290 96 456370183
423 26 410670897
4 350 842374799
682 80 966785586
301 7...

output:

0
162801811120260
4039747174200
166841558294460
8079494348400
170881305468660
12119241522600
174921052642860
16158988696800
178960799817060
20198735871000
183000546991260
24238483045200
187040294165460
28278230219400
191080041339660
32317977393600
195119788513860
36357724567800
199159535688060
40397...

result:

ok 796 lines

Test #48:

score: 0
Accepted
time: 3ms
memory: 4016kb

input:

746 400 799
398 400 263007380
328 503 827497866
303 335 366304434
35 164 767322249
261 497 494713262
308 507 199055419
11 358 73940591
399 279 276298522
48 129 377360470
340 81 913881737
135 39 430520399
99 714 974968512
193 35 448450111
274 431 713507943
393 215 51486384
185 580 31072218
266 439 33...

output:

0
153575892181
153557915316
153544685224
153578145049
153555491302
153581307946
153581843206
153550887349
153524649876
153576328025
153566530459
153575855567
153577336537
153574044629
153547807156
153567479820
153544826073
153554151181
153583287562
153540222120
153549547228
153574258974
153552446136...

result:

ok 799 lines

Test #49:

score: 0
Accepted
time: 3ms
memory: 3972kb

input:

800 200 798
58 97 904343657
5 405 82535629
87 297 437269975
171 792 395212785
4 123 446413815
109 553 671763753
132 797 245961359
40 718 529642773
129 157 145858479
105 497 253130948
94 385 855402552
75 515 485063179
108 788 812196623
55 362 962099492
180 320 886513264
191 514 568337862
32 626 17550...

output:

0
42704362319
42696813260
42704401106
42686551119
42702984843
42701406216
42689999040
42699483759
42702678574
42681781635
42694921936
42683514760
42698527978
42698874272
42703090559
42706234183
42697277144
42704289725
42688923825
42695024310
42694073551
42687486071
42683411243
42689219196
4269093399...

result:

ok 798 lines

Test #50:

score: 0
Accepted
time: 3ms
memory: 4016kb

input:

800 80 800
21 477 17676467
13 257 719326162
70 23 422986296
51 739 858634817
71 502 775938152
77 337 181418769
7 381 600288360
65 372 28293073
35 652 825791959
68 615 190306169
78 533 432318137
59 548 979796063
19 690 476478051
70 797 545393898
43 756 160959816
39 304 449387251
65 286 608558661
60 1...

output:

0
7194714900
7192147178
7196607964
7196946559
7195591286
7195613636
7195702084
7188338422
7190886419
7205825635
7204734009
7202735718
7200167996
7197305800
7204954027
7200294607
7198049067
7187645585
7196660434
7193498867
7183095385
7204306637
7196942975
7190020760
7205803157
7197031946
7190588682
7...

result:

ok 800 lines

Test #51:

score: 0
Accepted
time: 3ms
memory: 4056kb

input:

800 800 800
372 774 792764855
568 782 28843109
80 235 773021759
459 446 105905143
42 454 991288908
34 69 187530559
455 283 601212506
81 170 405267631
754 72 802675611
452 42 719202771
400 377 229727817
67 491 681023377
541 268 735962569
71 124 740723121
733 764 430420296
400 226 620752699
783 65 472...

output:

0
-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
-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
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-...

result:

ok 800 lines

Test #52:

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

input:

800 800 800
54 141 698438653
799 450 73030569
312 147 100238286
368 797 36253114
71 582 269799566
129 670 14563225
414 162 524295234
539 644 913953111
314 721 124747591
530 432 971018715
648 150 576170523
518 622 416584179
607 708 668356412
647 226 900331598
574 17 472798542
629 618 865679532
451 14...

output:

0
163342487279130
31709828230260
195052315509390
63419656460520
226762143739650
95129484690780
258471971969910
126839312921040
290181800200170
158549141151300
26916482102430
190258969381560
58626310332690
221968797611820
90336138562950
253678625842080
122045966793210
285388454072340
153755795023470
...

result:

ok 800 lines

Test #53:

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

input:

800 799 800
453 800 1000000000
135 800 1000000000
30 800 1000000000
565 800 1000000000
702 800 1000000000
379 800 1000000000
33 800 1000000000
156 800 1000000000
721 800 1000000000
748 800 1000000000
138 800 1000000000
518 800 1000000000
663 800 1000000000
429 800 1000000000
540 800 1000000000
318 8...

output:

0
799000000000
1598000000000
2397000000000
3196000000000
3995000000000
4794000000000
5593000000000
6392000000000
7191000000000
7990000000000
8789000000000
9588000000000
10387000000000
11186000000000
11985000000000
12784000000000
13583000000000
14382000000000
15181000000000
15980000000000
16779000000...

result:

ok 800 lines

Test #54:

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

input:

800 770 797
761 621 160
113 428 243
521 76 80
4 125 251
282 393 217
20 280 154
179 90 8
36 334 202
481 112 999998878
166 351 193
51 169 97
330 192 270
492 86 168
472 220 74
387 337 216
428 93 190
481 460 15
568 693 199
515 508 63
538 532 195
258 2 206
105 310 238
67 499 999981845
146 344 256
243 733...

output:

0
83482014
75317795
67153576
58989357
50825138
42660919
34496700
26332481
18168262
10004043
1839824
85321838
77157619
68993400
60829181
52664962
44500743
36336524
28172305
20008086
11843867
3679648
87161662
78997443
70833224
62669005
54504786
46340567
38176348
30012129
21847910
13683691
5519472
8900...

result:

ok 797 lines

Test #55:

score: 0
Accepted
time: 3ms
memory: 4108kb

input:

800 400 799
329 517 101
122 574 60
138 574 999855428
96 199 995307324
38 594 27
342 765 998313259
17 486 996380304
19 760 294
202 46 113
289 582 999985866
90 311 230
40 379 999408099
293 732 999904874
399 189 997560093
169 695 999437547
370 696 999982133
244 520 999887954
306 57 999986372
49 648 999...

output:

0
7143786
14287572
21431358
28575144
35718930
42862716
1221160
8364946
15508732
22652518
29796304
36940090
44083876
2442320
9586106
16729892
23873678
31017464
38161250
45305036
3663480
10807266
17951052
25094838
32238624
39382410
46526196
4884640
12028426
19172212
26315998
33459784
40603570
47747356...

result:

ok 799 lines

Test #56:

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

input:

800 266 796
41 437 999774476
175 416 999739970
99 734 39
131 691 999885548
154 665 13
88 218 132
52 696 976723666
248 233 151
149 100 212
102 620 142
234 717 994134357
124 109 998089276
197 178 999866499
88 572 998771808
208 144 286
142 552 247
13 468 972769035
168 742 998083015
174 789 995274069
22...

output:

0
-1
355914
-1
711828
-1
1067742
-1
1423656
-1
1779570
-1
2135484
-1
2491398
-1
2847312
-1
3203226
-1
3559140
-1
3915054
-1
4270968
-1
4626882
-1
4982796
-1
5338710
-1
5694624
-1
6050538
-1
6406452
-1
6762366
-1
7118280
-1
7474194
-1
7830108
-1
8186022
-1
8541936
-1
8897850
-1
9253764
-1
9609678
-1
...

result:

ok 796 lines

Test #57:

score: 0
Accepted
time: 3ms
memory: 4072kb

input:

800 770 798
650 368 33
624 6 1304
320 599 1215
487 143 323
542 391 412
182 474 1994
615 492 636
145 466 14
232 795 1886
71 713 1811
484 646 996562109
41 258 1965
201 172 1305
646 678 1197
310 741 1420
611 58 378
69 347 35
242 458 95
746 482 467
694 245 1959
479 114 1552
696 292 1810
516 116 843
141 ...

output:

0
-1
229846780
-1
159008756
-1
88170732
-1
17332708
-1
247179488
-1
176341464
-1
105503440
-1
34665416
-1
264512196
-1
193674172
-1
122836148
-1
51998124
-1
281844904
-1
211006880
-1
140168856
-1
69330832
-1
299177612
-1
228339588
-1
157501564
-1
86663540
-1
15825516
-1
245672296
-1
174834272
-1
103...

result:

ok 798 lines

Test #58:

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

input:

800 400 798
187 507 1863
258 110 994619813
172 515 1951
265 421 789
277 112 362
24 83 1056
218 232 979899099
331 349 571
384 728 991106242
165 19 603
19 275 1086
134 151 996072833
98 566 999971592
85 722 994382138
170 423 1681
305 218 1036
101 338 66
211 32 914
13 490 999742970
255 29 1821
380 224 9...

output:

0
-1
134824601
-1
110020075
-1
85215549
-1
60411023
-1
35606497
-1
10801971
-1
145626572
-1
120822046
-1
96017520
-1
71212994
-1
46408468
-1
21603942
-1
156428543
-1
131624017
-1
106819491
-1
82014965
-1
57210439
-1
32405913
-1
7601387
-1
142425988
-1
117621462
-1
92816936
-1
68012410
-1
43207884
-1...

result:

ok 798 lines

Test #59:

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

input:

800 266 800
216 520 70
61 342 999728546
183 133 999906142
71 69 999777755
122 441 999795765
53 53 997083771
168 558 999936353
34 327 995365075
253 418 992472899
125 326 999866400
177 716 1590
3 745 997397716
239 366 991721464
264 23 283
208 45 999109140
142 349 968804973
71 403 997465878
55 753 9950...

output:

0
-1
81983880
-1
53551760
-1
25119640
-1
107103520
-1
78671400
-1
50239280
-1
21807160
-1
103791040
-1
75358920
-1
46926800
-1
18494680
-1
100478560
-1
72046440
-1
43614320
-1
15182200
-1
97166080
-1
68733960
-1
40301840
-1
11869720
-1
93853600
-1
65421480
-1
36989360
-1
8557240
-1
90541120
-1
62109...

result:

ok 800 lines

Subtask #6:

score: 1
Accepted

Test #60:

score: 1
Accepted
time: 7ms
memory: 4184kb

input:

1399 1 1500
1 263 544868680
1 290 999206563
1 875 804782410
1 1079 719652502
1 209 729112964
1 1290 86457530
1 1182 232347286
1 186 455589032
1 1469 923937334
1 1388 798265205
1 733 210165866
1 588 833098851
1 878 11564261
1 266 808614572
1 920 290235334
1 122 23361011
1 234 531398460
1 471 67860757...

output:

0
16678216
20432062
16173833
10293524
16613173
9958948
21251961
15556313
17741612
17115637
9341428
17892880
19880638
18594055
14604217
15480156
13155773
16975993
18245157
15583143
9831901
13652121
15639879
17627637
15094690
18914910
16654014
8879805
12700025
16214377
13330142
5659366
15018533
188387...

result:

ok 1500 lines

Test #61:

score: 0
Accepted
time: 7ms
memory: 4124kb

input:

1436 2 1500
1 373 170242396
1 1004 747735130
2 954 389975059
1 963 197811484
2 1339 596292568
1 1098 221283957
2 319 916838940
1 92 9407811
2 1110 861910846
1 207 329834688
1 1454 962667548
1 1110 295107090
2 315 166804767
1 320 950075287
1 184 750924284
1 1193 477158724
1 460 501322060
2 1459 40573...

output:

0
15504124
17889980
17026570
22665779
21802369
20938959
20075549
18715967
17852557
16989147
18700866
22003102
17377474
19544968
18681558
17818148
20426453
17402293
20119404
17324712
16461302
18860035
21475257
12995218
22530079
18169052
20762018
19898608
16600558
15737148
19024045
17967504
17297225
1...

result:

ok 1500 lines

Test #62:

score: 0
Accepted
time: 3ms
memory: 4012kb

input:

1500 4 1497
1 454 489715965
1 773 461092239
1 880 982815770
4 417 366960051
3 143 767396295
4 274 740158900
3 1150 270022839
1 1495 747461947
4 97 670536673
4 189 557724841
4 1388 660642135
1 505 253676189
1 29 198538833
3 433 93629510
3 159 593292144
1 580 88324536
3 687 957931011
4 286 135320300
2...

output:

0
26365198
31938029
30488577
24262314
30673826
21418728
26406845
26656299
19848723
25968712
23353445
26019827
23311889
25035630
24604254
22448271
21073357
27122432
18328053
30178534
28810415
20435722
24434103
27164079
16148735
27922050
22102900
27973165
22234897
22754720
20356955
22805835
27335530
2...

result:

ok 1497 lines

Test #63:

score: 0
Accepted
time: 7ms
memory: 4080kb

input:

1500 38 1500
38 1081 33455781
11 1484 17218366
32 122 640497892
28 1273 520589600
18 1213 164577281
6 292 339139055
6 358 551600972
29 306 821370227
31 361 237841561
13 1361 661603567
33 954 894490309
33 997 506352796
15 1374 356737115
12 975 290191465
34 335 481442078
36 1061 576983432
11 112 60088...

output:

0
1003607414
1003597559
1014739909
1013606060
1014564656
1008404528
1010461010
1009356133
997231728
1000988282
1016402625
1008867544
1005263881
1010338515
1003387716
1014844792
1006279023
1008451931
1008442076
1009539505
1004392439
1001828488
1012524351
1012514496
1017156586
1002076245
1010105543
10...

result:

ok 1500 lines

Test #64:

score: 0
Accepted
time: 6ms
memory: 4120kb

input:

1500 1500 1500
515 1239 801457483
853 98 314888396
1112 511 19981247
161 34 84878716
1313 1440 784832799
371 961 897481212
1100 932 957805279
807 93 396412394
1093 753 720495755
1174 1443 989095704
347 1196 823260858
518 988 461764962
1066 441 222999081
1294 1293 294496104
253 1162 816689685
848 291...

output:

0
-1
-1
-1
-1
54212052588617
-1
-1
-1
-1
108424105177234
-1
-1
-1
-1
162636157765851
-1
-1
-1
-1
5632421048168
-1
-1
-1
-1
59844473636785
-1
-1
-1
-1
114056526225402
-1
-1
-1
-1
168268578814019
-1
-1
-1
-1
11264842096336
-1
-1
-1
-1
65476894684953
-1
-1
-1
-1
119688947273570
-1
-1
-1
-1
173900999862...

result:

ok 1500 lines

Test #65:

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

input:

1377 750 1500
372 244 991863806
342 399 668083881
323 1167 762110
372 1383 349256150
303 1393 885306368
574 164 527752824
384 753 954057656
212 574 9133992
145 375 803934241
213 1234 917562519
136 1186 13135733
666 665 855225985
320 133 790920306
206 641 735122446
331 531 646866872
214 1040 55591112...

output:

0
259498934720
259490676891
259489923165
259491106725
259498244280
259488877077
259484806863
259493942419
259502174366
259495678718
259496096104
259493449070
259498564954
259496261408
259496695402
259497549075
259490076561
259491470813
259490717087
259491900647
259499038202
259489670999
259504339678...

result:

ok 1500 lines

Test #66:

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

input:

1458 375 1498
139 974 955592641
288 438 296211276
20 494 53108919
161 869 7738452
127 445 119015437
47 849 601115206
299 975 102650677
324 960 500851176
303 1297 127448452
77 1485 597298895
248 1084 367532233
317 485 771456803
330 1174 198969896
38 670 204470179
184 1365 265024261
13 97 955327755
27...

output:

0
75741248367
75743052257
75738100525
75740311363
75748698750
75744846040
75747229509
75742768837
75749304279
75746511511
75744330796
75740581452
75735658844
75738916358
75743880289
75735768516
75746146191
75741373832
75742449345
75742296354
75737161984
75742375612
75735855587
75742302266
7574092283...

result:

ok 1498 lines

Test #67:

score: 0
Accepted
time: 7ms
memory: 4000kb

input:

1471 150 1500
6 1251 593115467
104 1330 245897258
22 899 33317971
8 870 791893796
94 1300 457642388
125 1331 760691998
17 405 729472856
2 1302 921141898
148 123 29562913
113 1425 921332598
26 1229 479981750
93 1469 361882679
36 569 241165014
107 1407 380905113
90 524 113950333
119 20 715390573
103 5...

output:

0
12525555813
12518839374
12525569368
12531104244
12519767000
12528681558
12524529678
12522284156
12526296240
12526604470
12525171992
12524489213
12529139641
12517267118
12521368266
12527683046
12527301251
12529408143
12519772003
12529449754
12515425704
12523233962
12530905684
12520808085
1252464175...

result:

ok 1500 lines

Test #68:

score: 0
Accepted
time: 6ms
memory: 4024kb

input:

1500 1500 1500
463 196 436309109
1008 568 347723766
629 586 136770969
520 239 768481322
401 1163 904703671
8 1406 84352004
572 1065 424079079
1 973 811118325
144 566 99460289
1036 1486 809192329
15 1197 306189374
578 1291 609062862
897 699 87794584
624 934 447529197
1095 706 86655664
931 893 7869766...

output:

0
-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
-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
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-...

result:

ok 1500 lines

Test #69:

score: 0
Accepted
time: 3ms
memory: 4040kb

input:

1500 1500 1500
366 397 784842198
321 969 543469174
112 5 910260692
854 203 583707856
1354 646 147271511
6 349 188689503
749 1180 860082830
944 1211 747817361
984 983 288812277
707 797 134459369
447 1381 848370968
960 598 372791224
479 1287 245652520
1151 1017 843115785
72 1363 265695135
1132 319 183...

output:

0
-1
-1
303892168769475
-1
-1
256869593001450
-1
-1
209847017233425
-1
-1
162824441465400
-1
-1
115801865697375
-1
-1
68779289929350
-1
-1
21756714161325
-1
-1
325648882930800
-1
-1
278626307162775
-1
-1
231603731394750
-1
-1
184581155626725
-1
-1
137558579858700
-1
-1
90536004090675
-1
-1
435134283...

result:

ok 1500 lines

Test #70:

score: 0
Accepted
time: 9ms
memory: 4244kb

input:

1500 1499 1500
866 1500 1000000000
22 1500 1000000000
1050 1500 1000000000
47 1500 1000000000
1046 1500 1000000000
1222 1500 1000000000
603 1500 1000000000
1010 1500 1000000000
960 1500 1000000000
1380 1500 1000000000
685 1500 1000000000
1132 1500 1000000000
16 1500 1000000000
197 1500 1000000000
81...

output:

0
1499000000000
2998000000000
4497000000000
5996000000000
7495000000000
8994000000000
10493000000000
11992000000000
13491000000000
14990000000000
16489000000000
17988000000000
19487000000000
20986000000000
22485000000000
23984000000000
25483000000000
26982000000000
28481000000000
29980000000000
3147...

result:

ok 1500 lines

Test #71:

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

input:

1500 1470 1499
523 359 207
1286 1184 14
568 367 89
274 1435 208
783 1216 125
408 237 19
1032 962 180
98 256 250
1398 538 291
1448 740 49
699 1093 295
218 1306 21
250 1366 96
433 1291 242
962 181 12
1189 1177 83
1116 1258 85
1113 514 14
1156 851 202
414 1248 76
616 236 68
426 295 202
1025 1252 81
445...

output:

0
182552552
25593596
208146148
51187192
233739744
76780788
259333340
102374384
284926936
127967980
310520532
153561576
336114128
179155172
22196216
204748768
47789812
230342364
73383408
255935960
98977004
281529556
124570600
307123152
150164196
332716748
175757792
18798836
201351388
44392432
2269449...

result:

ok 1499 lines

Test #72:

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

input:

1500 750 1500
29 806 43
250 180 31
735 154 986254277
583 752 999335692
642 183 35
159 260 979529493
611 620 71
700 203 998198669
750 1024 197
421 359 167
609 1498 998411594
672 1446 982213528
455 895 989567153
686 479 92
258 1494 206
282 331 233
599 593 999922479
404 131 998931729
311 946 999948510
...

output:

0
-1
-1
-1
-1
-1
21150576
-1
-1
-1
-1
-1
14617152
-1
-1
-1
-1
-1
8083728
-1
-1
-1
-1
-1
1550304
-1
-1
-1
-1
-1
22700880
-1
-1
-1
-1
-1
16167456
-1
-1
-1
-1
-1
9634032
-1
-1
-1
-1
-1
3100608
-1
-1
-1
-1
-1
24251184
-1
-1
-1
-1
-1
17717760
-1
-1
-1
-1
-1
11184336
-1
-1
-1
-1
-1
4650912
-1
-1
-1
-1
-1
...

result:

ok 1500 lines

Test #73:

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

input:

1500 500 1500
176 579 999925429
356 695 999449176
270 1224 97
221 1192 999992084
136 324 998222472
257 1308 984084021
141 1291 982050955
459 563 998440014
428 125 237
367 370 998109558
87 677 999939793
123 120 996316967
445 1275 183
100 1240 999996118
242 783 999975779
361 126 994135356
52 769 39
33...

output:

0
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
5467554
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
5317758
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
5167962
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
5018166
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1...

result:

ok 1500 lines

Test #74:

score: 0
Accepted
time: 9ms
memory: 4124kb

input:

1500 1470 1496
1287 992 266
1392 371 1005
605 1394 1367
992 510 461
1345 29 1617
1028 362 846
263 556 865
792 1347 582
481 130 550
357 1021 1775
396 1053 973
864 1021 723
1016 50 245
1067 1036 650
599 1259 1000
72 562 807
1050 1131 988
50 1284 1908
1005 281 155
954 308 1494
1379 1041 402
329 568 135...

output:

0
1535802535
893822518
251842501
1787645036
1145665019
503685002
2039487537
1397507520
755527503
113547486
1649350021
1007370004
365389987
1901192522
1259212505
617232488
2153035023
1511055006
869074989
227094972
1762897507
1120917490
478937473
2014740008
1372759991
730779974
88799957
1624602492
982...

result:

ok 1496 lines

Test #75:

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

input:

1500 750 1495
730 422 610
145 1209 996649057
240 307 207
555 376 996472461
654 483 999773352
320 44 999711243
283 361 948208420
45 724 997659570
128 371 1124
481 316 999972109
413 487 1815
68 591 729
660 878 996161630
611 320 984115068
43 30 1026
238 199 1338
199 515 999480354
538 1353 1166
537 38 9...

output:

0
369116495
738232990
1107349485
357137055
726253550
1095370045
345157615
714274110
1083390605
333178175
702294670
1071411165
321198735
690315230
1059431725
309219295
678335790
1047452285
297239855
666356350
1035472845
285260415
654376910
1023493405
273280975
642397470
1011513965
261301535
630418030...

result:

ok 1495 lines

Test #76:

score: 0
Accepted
time: 6ms
memory: 4076kb

input:

1500 500 1500
357 399 997316259
296 1435 1103
388 1308 999930249
126 192 997929393
496 1190 998858661
334 7 999467428
316 1187 999850806
305 867 999581278
434 1010 1837
32 1136 999791502
380 1084 999775361
177 180 999923556
136 1402 998619757
188 754 995448456
431 1286 999994655
174 1034 999912201
2...

output:

0
-1
279742667
-1
182812084
-1
85881501
-1
365624168
-1
268693585
-1
171763002
-1
74832419
-1
354575086
-1
257644503
-1
160713920
-1
63783337
-1
343526004
-1
246595421
-1
149664838
-1
52734255
-1
332476922
-1
235546339
-1
138615756
-1
41685173
-1
321427840
-1
224497257
-1
127566674
-1
30636091
-1
31...

result:

ok 1500 lines

Subtask #7:

score: 1
Accepted

Test #77:

score: 1
Accepted
time: 18ms
memory: 4132kb

input:

2500 1 2498
1 994 715506365
1 1815 734891325
1 1250 666540841
1 954 686418040
1 2262 95160282
1 1979 505324999
1 711 702777591
1 2231 38539883
1 1861 361026549
1 1326 904653089
1 550 157156353
1 1923 411409063
1 1323 811600580
1 82 948165057
1 848 551130589
1 2206 883158572
1 1587 234387803
1 1639 5...

output:

0
9159065
10859949
10335972
7344000
9044884
8520907
9901255
7912098
6718366
9625656
9285924
8911100
8278928
7483383
7096035
8289418
5668318
10089965
8547695
3853253
8274900
6791683
6335429
7995838
6802106
8144642
7633189
10540479
6329577
7208775
8909659
8385682
8010858
7378686
6570617
10203592
91506...

result:

ok 2498 lines

Test #78:

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

input:

2334 2 2500
2 1621 863026878
1 875 483806084
2 2439 484933124
2 698 604248116
1 2386 157736705
2 232 66464090
2 343 741754888
1 1139 523063631
2 2498 939965336
1 310 340866658
1 476 541885406
2 1459 884702899
1 2206 209127743
2 811 278746311
2 558 869825249
2 340 398226659
1 1274 764391346
2 1356 87...

output:

0
6897539
6524917
5923350
4619147
8057765
5517811
4584044
5112783
8037183
7719838
4707244
5690867
6540996
7226616
6050049
6088178
8085638
6751845
6053075
6581814
6346306
7453130
6176275
7159898
7136096
4966578
4630782
7557209
4561039
5960528
7416207
7391527
6763066
5485757
6985988
6605640
8566487
64...

result:

ok 2500 lines

Test #79:

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

input:

2378 4 2499
3 2479 536173180
3 2039 119671670
2 707 255644062
4 544 753339876
1 1881 743876751
4 1067 537759585
4 2104 137384184
2 2152 806076190
2 214 295612797
3 1133 778069218
2 919 167958360
3 2338 19421192
3 1561 726921846
2 502 32757067
2 1554 745991405
4 1744 322755179
1 787 18714084
2 1025 9...

output:

0
14955355
29910710
23667676
28966961
34869503
24723765
29550372
17204936
32160291
32837589
31255208
26952387
26973346
30146464
23309142
31155342
34809309
39427418
35830514
32717350
36817134
31540506
33218422
30871540
19383403
21514061
29265586
30864400
34140659
31072123
29662033
24985216
26926485
1...

result:

ok 2499 lines

Test #80:

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

input:

2266 50 2499
48 1370 608359820
2 2238 959198725
40 994 357796689
18 964 394577435
41 1521 452621374
9 47 279387596
11 1500 423112793
19 1754 992598311
49 789 215943696
40 988 342533736
3 865 887919533
47 73 567323242
15 316 402637436
35 577 288904148
47 749 83363281
34 1998 487348371
1 971 132171934...

output:

0
979497831
976105286
978262229
980142957
978373025
977590395
975953107
977460111
978714936
973091420
982071924
981155285
975845783
975546028
970674475
977657398
976809760
979129015
976385580
980502261
975491517
978908592
981330558
978409245
975286525
975125961
980528606
968909454
978854081
97734508...

result:

ok 2499 lines

Test #81:

score: 0
Accepted
time: 21ms
memory: 4164kb

input:

2265 2265 2500
1786 817 946997159
2109 561 347356494
2114 2175 799605655
1519 61 750217037
1222 73 14235474
1405 1522 887298492
160 1192 896868468
940 1791 228796686
1030 1568 701915
105 2282 473825869
1800 1098 247774741
1647 2498 475056749
2100 2068 44395295
1325 1038 703312611
489 1510 312014998
...

output:

0
232304457696534
464608915393068
696913373089602
929217830786136
1161522288482670
1393826746179204
1626131203875738
1858435661572272
2090740119268806
2323044576965340
2555349034661874
135776121393408
368080579089942
600385036786476
832689494483010
1064993952179544
1297298409876078
1529602867572612
...

result:

ok 2500 lines

Test #82:

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

input:

2500 1250 2496
873 1441 914204928
696 249 93616724
11 802 674754407
1001 458 300080716
479 442 9239834
330 1587 696326412
928 459 866722020
261 2133 819496171
1056 72 631728209
10 443 97773508
259 449 384909875
812 40 285001893
342 621 728342571
504 1547 665881896
707 1227 548600371
59 1461 92749062...

output:

0
427830581450
427822458461
427827474736
427830813936
427828659906
427829721142
427831622024
427829471378
427828907153
427825016007
427829453768
427828328867
427825824095
427830261856
427829136955
427827247421
427828908962
427829664071
427830532744
427831133597
427832635565
427828026883
427830720038...

result:

ok 2496 lines

Test #83:

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

input:

2500 625 2500
613 2088 206282087
593 1188 448176660
98 1750 582475052
465 548 146990079
390 1231 785022490
236 2083 898785827
258 437 461800751
265 767 921665605
227 2332 374671425
492 1022 263091225
484 701 926200520
385 1361 49595448
126 1690 214484478
415 739 936561023
425 103 222050798
229 297 3...

output:

0
129468826580
129473669749
129465144078
129469964558
129467529633
129475531653
129471051391
129469046276
129473624494
129470919478
129468969019
129472368455
129477012384
129472662641
129469676562
129469260614
129471276564
129475024225
129476249084
129471622429
129476457676
129471165760
129462640089...

result:

ok 2500 lines

Test #84:

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

input:

2418 250 2500
57 1878 979111313
198 80 153011943
114 1314 95592736
143 1645 204449876
183 1079 831548484
74 403 74513838
83 852 5153107
53 1735 147151140
98 2328 516767825
92 1837 271267152
16 2269 583212897
247 1511 479294833
78 872 15186625
134 2268 556824653
221 2208 230790883
65 1755 985444793
2...

output:

0
22329216375
22331661705
22332400044
22336161149
22334770108
22330089316
22332692143
22331539315
22333115572
22335358272
22333405105
22329509820
22328330146
22333504939
22332305015
22335957330
22329614217
22330970488
22333573315
22335188988
22327760884
22334627955
22330793941
22332639276
2233517816...

result:

ok 2500 lines

Test #85:

score: 0
Accepted
time: 11ms
memory: 4164kb

input:

2500 2500 2500
2461 978 512669841
692 703 160404913
1127 2360 815347251
293 2351 841834988
669 1022 760079
1867 2449 464195758
49 1236 143133917
1341 911 994378733
632 1009 532680898
1041 1580 288144646
1253 172 347935665
511 2322 158866754
712 147 285029992
347 2262 150587666
1837 2100 389472638
20...

output:

0
-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
-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
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-...

result:

ok 2500 lines

Test #86:

score: 0
Accepted
time: 22ms
memory: 4148kb

input:

2500 2500 2500
2499 1604 176913664
1537 1634 61731453
1031 2373 685412921
684 1843 338828465
99 487 338741873
1613 2369 906277124
160 1864 655950727
2404 2461 192906797
881 615 264297981
1343 899 470033582
1039 2234 511588002
1213 1914 711481160
1149 1690 809783729
625 1760 228487614
269 1811 965672...

output:

0
2643514060901073
2340623684774646
2037733308648219
1734842932521792
1431952556395365
1129062180268938
826171804142511
523281428016084
220391051889657
2863905112790730
2561014736664303
2258124360537876
1955233984411449
1652343608285022
1349453232158595
1046562856032168
743672479905741
4407821037793...

result:

ok 2500 lines

Test #87:

score: 0
Accepted
time: 20ms
memory: 4332kb

input:

2500 2499 2500
930 2500 1000000000
221 2500 1000000000
2162 2500 1000000000
42 2500 1000000000
1072 2500 1000000000
1220 2500 1000000000
444 2500 1000000000
358 2500 1000000000
2368 2500 1000000000
1796 2500 1000000000
2101 2500 1000000000
1709 2500 1000000000
1193 2500 1000000000
796 2500 100000000...

output:

0
2499000000000
4998000000000
7497000000000
9996000000000
12495000000000
14994000000000
17493000000000
19992000000000
22491000000000
24990000000000
27489000000000
29988000000000
32487000000000
34986000000000
37485000000000
39984000000000
42483000000000
44982000000000
47481000000000
49980000000000
52...

result:

ok 2500 lines

Test #88:

score: 0
Accepted
time: 14ms
memory: 4240kb

input:

2500 2470 2496
548 1379 157
906 1057 282
881 527 186
1081 1654 162
685 1415 24
300 278 82
332 2359 185
2043 1106 23
1444 906 989967218
1594 33 35
1080 960 20
2327 2270 250
399 529 202
1152 959 210
1588 1316 264
2289 1970 109
675 419 269
1349 1243 113
377 2394 168
490 2251 214
2149 1505 12
368 2131 1...

output:

0
-1
-1
19319772
-1
-1
38639544
-1
-1
57959316
-1
-1
77279088
-1
-1
96598860
-1
-1
115918632
-1
-1
135238404
-1
-1
154558176
-1
-1
173877948
-1
-1
193197720
-1
-1
212517492
-1
-1
231837264
-1
-1
251157036
-1
-1
270476808
-1
-1
289796580
-1
-1
5832384
-1
-1
25152156
-1
-1
44471928
-1
-1
63791700
-1
-...

result:

ok 2496 lines

Test #89:

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

input:

2500 1250 2500
547 1928 168
730 2176 999827063
284 1153 211
32 1185 999758455
109 988 72
276 1425 72
326 829 999998524
70 2082 184
146 1937 999576954
509 1812 995150781
681 2120 971729254
137 598 99
1182 1447 999629943
118 58 993293178
1024 1153 13
751 260 997884059
400 1670 51
80 402 86
1118 772 99...

output:

0
341351064
210962128
80573192
421924256
291535320
161146384
30757448
372108512
241719576
111330640
452681704
322292768
191903832
61514896
402865960
272477024
142088088
11699152
353050216
222661280
92272344
433623408
303234472
172845536
42456600
383807664
253418728
123029792
464380856
333991920
2036...

result:

ok 2500 lines

Test #90:

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

input:

2500 833 2497
263 1222 137
5 798 270
200 2147 999950090
201 464 81
58 899 279
235 861 983695417
386 1935 24
795 1654 985842082
621 1808 997674524
453 1664 987029754
183 810 18
202 1511 998684383
596 706 50
468 1616 999930735
556 989 14
90 1961 174
263 1104 985978389
16 1671 998289044
449 2345 991948...

output:

0
237310423
152750055
68189687
305500110
220939742
136379374
51819006
289129429
204569061
120008693
35448325
272758748
188198380
103638012
19077644
256388067
171827699
87267331
2706963
240017386
155457018
70896650
308207073
223646705
139086337
54525969
291836392
207276024
122715656
38155288
27546571...

result:

ok 2497 lines

Test #91:

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

input:

2500 2470 2500
629 639 132
507 2475 1798
1681 146 199
2319 2257 1672
1248 2447 1378
1237 586 644
2324 1483 1110
2265 1518 1762
903 1482 753
484 757 104
2218 616 60
2312 2039 504
815 769 1128
1825 2262 1565
2061 1300 653
1419 2355 1984
1999 736 1616
267 263 843
1005 578 1364
1280 1125 861
2329 877 26...

output:

0
-1
1534770265
-1
3069540530
-1
1505017045
-1
3039787310
-1
1475263825
-1
3010034090
-1
1445510605
-1
2980280870
-1
1415757385
-1
2950527650
-1
1386004165
-1
2920774430
-1
1356250945
-1
2891021210
-1
1326497725
-1
2861267990
-1
1296744505
-1
2831514770
-1
1266991285
-1
2801761550
-1
1237238065
-1
2...

result:

ok 2500 lines

Test #92:

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

input:

2500 1250 2495
143 246 998866736
961 1170 46
473 257 999966540
799 914 999977738
970 1460 446
579 589 999966245
450 1611 994679856
791 2231 998956960
132 1239 1823
16 933 993438868
884 544 1204
1227 2047 994607734
718 2400 999810693
611 809 999995805
388 732 1175
199 1917 990926937
590 2468 77
288 6...

output:

0
536007144
1072014288
1608021432
2144028576
2680035720
3216042864
474261223
1010268367
1546275511
2082282655
2618289799
3154296943
412515302
948522446
1484529590
2020536734
2556543878
3092551022
350769381
886776525
1422783669
1958790813
2494797957
3030805101
289023460
825030604
1361037748
189704489...

result:

ok 2495 lines

Test #93:

score: 0
Accepted
time: 15ms
memory: 4044kb

input:

2500 833 2495
28 1782 999992029
229 1579 996939694
324 2334 987133289
107 1115 999865718
626 213 1832
355 565 1573
683 1389 535
140 525 999956805
171 1937 999456691
381 917 995663322
830 1507 970734191
664 1410 463
121 418 999874304
252 544 997054685
195 395 993918023
802 1028 999841924
524 711 9983...

output:

0
738764236
1477528472
186318293
925082529
1663846765
372636586
1111400822
1850165058
558954879
1297719115
6508936
745273172
1484037408
192827229
931591465
1670355701
379145522
1117909758
1856673994
565463815
1304228051
13017872
751782108
1490546344
199336165
938100401
1676864637
385654458
112441869...

result:

ok 2495 lines

Test #94:

score: 0
Accepted
time: 7ms
memory: 4052kb

input:

2403 357 2500
81 1491 736130363
134 1357 94479889
176 248 832327252
106 401 500865769
13 1901 267017037
188 1491 566007365
105 293 521976648
344 2310 35653874
229 400 678385536
272 2056 458495799
312 2004 501813783
234 1505 690929593
1 1896 731851773
111 543 747865518
36 1157 308844039
176 2448 6878...

output:

0
-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
-1
-1
-1
-1
-1
-1
-1
-1
42318680542
-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
-1
-1
-1
-1
-1
-...

result:

ok 2500 lines

Subtask #8:

score: 1
Accepted

Test #95:

score: 1
Accepted
time: 44ms
memory: 4116kb

input:

3848 1 4000
1 748 287898462
1 3171 189919103
1 1947 387084552
1 1363 174715833
1 1003 663176974
1 2478 787185490
1 3138 45305696
1 142 27365385
1 2304 244788155
1 701 247246135
1 1957 77305315
1 3900 692059517
1 1194 582849043
1 3036 147567095
1 738 307083645
1 830 875184065
1 2273 758715995
1 704 5...

output:

0
1565898
3131796
2474146
3082974
2280028
3818735
3092627
2374998
3305359
1690639
996438
2562336
947616
2513514
3194114
2464692
2649264
2117711
3327738
2041698
2687077
1992876
2638255
1944054
2807070
1749936
3315834
2976952
2030982
1818197
1160547
2699254
2706331
2677623
2940492
3440575
2746374
3076...

result:

ok 4000 lines

Test #96:

score: 0
Accepted
time: 41ms
memory: 4224kb

input:

4000 2 3995
1 979 592867853
1 216 613645707
1 42 977030204
2 2002 832921210
2 3246 865348970
1 2030 63570696
2 3130 319255296
1 3132 189300278
1 2722 198182030
2 1804 570739549
1 252 949724573
2 295 154391400
2 299 271745606
1 3123 194905085
1 828 603988348
1 538 863942242
2 1591 974518831
2 3900 76...

output:

0
8809318
11088283
8388894
12659929
9632406
13493017
9542992
12429468
7916917
12867362
11035008
11771346
10358014
12079246
10315469
10977752
10226055
9883205
8599980
11998021
12700788
8370092
9884359
13642913
9966162
9274287
9847508
12432580
9075406
12869519
9189386
11038137
11438973
11421566
860489...

result:

ok 3995 lines

Test #97:

score: 0
Accepted
time: 45ms
memory: 4288kb

input:

3893 4 4000
1 1538 317712768
3 978 191189949
4 1205 273819001
3 3778 444751440
2 627 989377447
3 1054 745026262
2 515 832472446
4 886 52560851
1 2542 533683947
3 625 938386723
3 2904 427348879
3 1778 53658936
2 1732 269001907
2 564 339837146
1 2775 202516496
1 2713 813566606
3 2487 420470945
1 3261 ...

output:

0
8530949
9210524
9994318
9299476
10675836
9744680
12131255
11171835
10598899
4790599
7465284
8054500
9581967
11758828
11521711
7955046
10086767
7110445
8723573
9038717
11162532
8074069
9549699
11094294
11047643
4918972
7478597
11469020
10537864
8892122
11965019
10978294
9660649
8258468
11114202
970...

result:

ok 4000 lines

Test #98:

score: 0
Accepted
time: 46ms
memory: 4092kb

input:

3905 63 3995
39 3051 16172557
2 821 254635441
28 1061 506828092
11 2665 520053241
16 1683 70418405
37 148 690884981
17 281 419036742
21 2368 558650959
58 235 505642988
41 281 678544477
58 1316 242733031
29 9 642946309
59 175 319656532
56 1615 607990852
23 1144 923265685
55 2718 309925060
40 3151 118...

output:

0
849523240
850324183
848659963
851680010
850180172
849518484
852907817
851869307
850831463
850798461
848020730
850976884
851583450
850136741
852046342
850630741
846826233
850793673
849796419
850908673
851044332
848541496
851315477
848634231
852279786
848749231
849749720
851695686
852331520
85230728...

result:

ok 3995 lines

Test #99:

score: 0
Accepted
time: 47ms
memory: 4336kb

input:

4000 4000 4000
3545 2926 981473609
2588 3318 961163619
3318 2652 788820909
2215 720 919953026
2405 1198 307228526
3447 2431 550586055
2068 2090 659972750
3777 566 516387188
1405 3157 314592310
3062 3485 428243780
849 3243 151764915
3248 560 764948282
3576 3702 255168452
2858 1748 225414758
1273 1618...

output:

0
7651715050714080
7607463241268160
7563211431822240
7518959622376320
7474707812930400
7430456003484480
7386204194038560
7341952384592640
7297700575146720
7253448765700800
7209196956254880
7164945146808960
7120693337363040
7076441527917120
7032189718471200
6987937909025280
6943686099579360
689943429...

result:

ok 4000 lines

Test #100:

score: 0
Accepted
time: 49ms
memory: 4244kb

input:

3889 2000 4000
441 2102 182553407
808 3727 550239661
378 3726 642152331
1382 2391 373511072
1611 218 314583512
784 208 547529793
1472 1115 436831375
1681 3568 181358567
27 1714 418621025
653 2643 911707294
1822 3057 950296766
438 3590 802696791
664 1404 532172894
1223 2789 98563709
1753 2738 4609531...

output:

0
692200667337
692199832938
692203620580
692202566084
692201149764
692203967149
692198408252
692192399784
692196026681
692199086164
692202353915
692201988620
692199176271
692197778355
692205378951
692202155684
692203838698
692203695409
692198423386
692203195473
692200505074
692204857934
692204710684...

result:

ok 4000 lines

Test #101:

score: 0
Accepted
time: 48ms
memory: 4188kb

input:

4000 1000 3996
929 2430 674643216
675 1180 820708442
440 2 344709236
103 175 291839637
810 849 770221228
134 2541 183988957
808 2861 210737864
341 1685 920093498
577 1501 804251978
390 2601 455420487
977 1655 93333476
457 290 277362833
209 1146 963277097
163 3243 113891083
164 2838 718274682
735 179...

output:

0
203325980332
203325473211
203327845161
203325593903
203323995173
203325740349
203330596508
203322598187
203324779634
203329184792
203327687366
203325476063
203326268672
203326290380
203329693727
203328953903
203325883056
203328450004
203325763017
203326035976
203328812485
203326311582
203328353775...

result:

ok 3996 lines

Test #102:

score: 0
Accepted
time: 46ms
memory: 4240kb

input:

3774 400 4000
30 1764 488372709
19 673 121710925
316 3656 366124634
11 2080 963053547
241 1250 222462953
392 3588 275625307
125 3378 628788035
342 1712 462707297
311 3094 443190098
313 3003 965107288
163 765 447073416
335 2391 785656331
376 2299 471437251
287 1003 621798600
275 2434 615156868
293 21...

output:

0
35302410907
35301185794
35303009579
35305823508
35300771630
35298251426
35301728869
35300034263
35301348209
35304677453
35303131046
35303327735
35302239146
35302020549
35299713307
35302567114
35304048459
35299492164
35299212389
35304742728
35301587346
35304223958
35303370183
35304255004
3530064196...

result:

ok 4000 lines

Test #103:

score: 0
Accepted
time: 23ms
memory: 4268kb

input:

4000 4000 4000
1380 2643 435068551
2799 2669 992545391
1032 1805 120883485
3497 3662 41622297
2682 1608 865331526
539 1718 305240580
2825 2839 488937961
304 3225 274498665
1504 405 310489395
3582 1254 114418825
2404 3292 558951441
1974 200 506595808
924 3246 183404349
751 998 569069673
3071 493 4679...

output:

0
-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
-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
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-...

result:

ok 4000 lines

Test #104:

score: 0
Accepted
time: 46ms
memory: 4280kb

input:

4000 4000 4000
2487 1652 546245740
3991 1551 234117977
3999 3607 896790764
2737 1661 305555366
3929 1712 186784432
2880 536 17538881
3479 1419 589864947
2427 939 293604277
3026 1085 175142307
3624 1679 530835520
2745 3400 500221337
3039 3303 663583115
3857 2353 977388736
2336 1588 261052851
1116 302...

output:

0
5171622602000694
2746296835289388
320971068578082
5492593670578776
3067267903867470
641942137156164
5813564739156858
3388238972445552
962913205734246
6134535807734940
3709210041023634
1283884274312328
6455506876313022
4030181109601716
1604855342890410
6776477944891104
4351152178179798
192582641146...

result:

ok 4000 lines

Test #105:

score: 0
Accepted
time: 46ms
memory: 4388kb

input:

4000 3999 4000
1133 4000 1000000000
1123 4000 1000000000
2689 4000 1000000000
3611 4000 1000000000
1744 4000 1000000000
1029 4000 1000000000
1812 4000 1000000000
669 4000 1000000000
1069 4000 1000000000
1825 4000 1000000000
3783 4000 1000000000
1036 4000 1000000000
1171 4000 1000000000
1426 4000 100...

output:

0
3999000000000
7998000000000
11997000000000
15996000000000
19995000000000
23994000000000
27993000000000
31992000000000
35991000000000
39990000000000
43989000000000
47988000000000
51987000000000
55986000000000
59985000000000
63984000000000
67983000000000
71982000000000
75981000000000
79980000000000
...

result:

ok 4000 lines

Test #106:

score: 0
Accepted
time: 49ms
memory: 4328kb

input:

4000 3970 4000
227 3965 134
450 2892 99
3480 2238 199
471 1125 283
2216 930 50
2970 2292 241
3659 1251 175
1480 1718 104
1187 1107 253
3416 20 169
2558 1121 106
3653 3115 129
2399 3806 226
3798 3157 156
2560 3544 24
2480 2070 282
46 3653 278
3029 2826 221
3964 3290 68
1784 898 185
3164 825 273
2370 ...

output:

0
297364782
594729564
892094346
1189459128
1486823910
1784188692
2081553474
2378918256
263587038
560951820
858316602
1155681384
1453046166
1750410948
2047775730
2345140512
229809294
527174076
824538858
1121903640
1419268422
1716633204
2013997986
2311362768
196031550
493396332
790761114
1088125896
13...

result:

ok 4000 lines

Test #107:

score: 0
Accepted
time: 46ms
memory: 4276kb

input:

4000 2000 3996
1964 2608 959470128
1121 1766 999859258
126 3632 997469074
225 1940 71
500 33 2
966 3888 65
1712 892 999917502
426 361 261
547 3797 177
456 715 995955877
666 678 999998778
1096 3144 123
1295 2320 998333369
1076 2249 122
1389 1112 20
831 724 256
1024 3469 21
1094 3119 139
1300 850 100
...

output:

0
88404546
176809092
265213638
353618184
442022730
530427276
618831822
707236368
795640914
884045460
972450006
1060854552
1149259098
31982532
120387078
208791624
297196170
385600716
474005262
562409808
650814354
739218900
827623446
916027992
1004432538
1092837084
1181241630
63965064
152369610
240774...

result:

ok 3996 lines

Test #108:

score: 0
Accepted
time: 14ms
memory: 4212kb

input:

4000 1333 4000
38 3597 996657854
721 2896 219
1300 373 999555617
23 1959 999363947
575 838 999978747
284 3937 144
1113 2919 999899748
222 3238 187
920 1860 940040743
464 649 999685428
1020 333 999765039
1145 3279 79
156 1999 992709012
464 3409 1
460 3948 997136785
240 522 999998757
514 826 999169034...

output:

0
-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
14321623
-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
8471946
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1...

result:

ok 4000 lines

Test #109:

score: 0
Accepted
time: 50ms
memory: 4296kb

input:

4000 3970 3995
3615 3936 1049
2892 3007 110
2589 1251 446
683 3849 1896
396 1266 1801
2532 1915 1981
588 3332 1803
599 2193 1476
830 3459 1986
319 1706 436
550 3623 1903
1347 2499 66
2517 913 1417
1824 645 203
2708 3976 1879
3502 663 1108
2158 3047 1637
1736 105 97
658 3905 1104
2989 2760 593
3725 7...

output:

0
9578910276
3152907732
12731818008
6305815464
15884725740
9458723196
3032720652
12611630928
6185628384
15764538660
9338536116
2912533572
12491443848
6065441304
15644351580
9218349036
2792346492
12371256768
5945254224
15524164500
9098161956
2672159412
12251069688
5825067144
15403977420
8977974876
25...

result:

ok 3995 lines

Test #110:

score: 0
Accepted
time: 46ms
memory: 4164kb

input:

4000 2000 3995
653 3031 959075309
66 3351 994751232
145 36 73
1019 1824 1023
154 411 999821259
827 2226 307
760 3638 1163
1085 2160 978048747
1975 3265 594
390 2366 658
1959 689 999987191
286 3768 25
133 1878 760
1617 3268 74
762 677 999862247
1240 2858 51
295 1524 121
699 781 710
1209 2308 477
850 ...

output:

0
4900749556
1868559697
6769309253
3737119394
704929535
5605679091
2573489232
7474238788
4442048929
1409859070
6310608626
3278418767
246228908
5146978464
2114788605
7015538161
3983348302
951158443
5851907999
2819718140
7720467696
4688277837
1656087978
6556837534
3524647675
492457816
5393207372
23610...

result:

ok 3995 lines

Test #111:

score: 0
Accepted
time: 28ms
memory: 4280kb

input:

4000 1333 3996
599 3937 997747632
257 1874 495
650 1534 962
1202 1634 999106925
1230 2097 999215041
371 1360 999949931
796 400 467
552 2474 1887
237 1272 999966430
58 1452 607
1234 846 481
736 2424 999698644
1263 3451 1083
1175 3079 999804545
19 3875 1698
454 1435 999987777
125 2487 1504
710 1400 79...

output:

0
-1
1946437497
-1
1249107408
-1
551777319
-1
2498214816
-1
1800884727
-1
1103554638
-1
406224549
-1
2352662046
-1
1655331957
-1
958001868
-1
260671779
-1
2207109276
-1
1509779187
-1
812449098
-1
115119009
-1
2061556506
-1
1364226417
-1
666896328
-1
2613333825
-1
1916003736
-1
1218673647
-1
52134355...

result:

ok 3996 lines

Subtask #9:

score: 1
Accepted

Test #112:

score: 1
Accepted
time: 83ms
memory: 4324kb

input:

5085 1 5500
1 3115 347998312
1 3328 620074883
1 3270 773526310
1 5334 149071507
1 3571 352409431
1 3069 74139647
1 3868 707421
1 840 376823954
1 470 441302501
1 4338 266055350
1 4379 849545435
1 2548 641098179
1 4206 721541228
1 4425 998420717
1 2571 413570512
1 5267 120149238
1 4843 231635395
1 500...

output:

0
5096353
4771120
4649471
4116552
4340005
3199675
2097974
3719624
4428784
3288454
4213316
3886646
5297649
4195948
4913307
3130298
4739322
4777936
3566065
3219077
3260903
5328258
4880362
2822149
4253973
4506126
3401943
3893462
5141248
4566205
3425875
3947117
4024067
4092179
2668590
3585313
3267719
46...

result:

ok 5500 lines

Test #113:

score: 0
Accepted
time: 88ms
memory: 4240kb

input:

5500 2 5497
1 4518 912027014
2 3134 255217125
1 3033 638480327
2 179 54793390
1 4334 26948855
1 102 160418719
2 3415 219577442
1 3908 638121930
2 4022 497752986
2 2234 452611131
2 3814 761724654
1 2912 58687248
2 473 982298769
2 4590 431585499
1 5218 854010338
2 1529 583476175
2 4358 178372419
2 140...

output:

0
7439019
5728027
7289622
6318710
6479443
5398891
7319284
4792277
7208535
8190654
7118981
6829609
8270844
6918644
7664161
7279195
5478018
7075784
5388464
5099092
5507680
7189229
7985604
7099675
5298498
7810243
6953810
7616254
5988398
5176687
5898844
4097667
5695433
4008113
2206936
7570665
7934963
66...

result:

ok 5497 lines

Test #114:

score: 0
Accepted
time: 90ms
memory: 4188kb

input:

5500 4 5500
4 352 936569716
2 3845 306616495
2 3316 397123432
3 883 545622313
3 4290 476755391
3 1083 105163469
4 4578 722989547
4 960 228508840
2 970 544383111
4 4637 646662649
3 3068 560949698
1 3946 24860521
3 4022 304417479
4 2416 662179040
4 2261 830636210
1 555 101276422
1 3584 914276469
4 194...

output:

0
6224118
6483141
5857767
3851214
4648719
6610773
4281792
6243846
4913952
4908348
5203399
2588805
6317720
6175873
5634585
6440019
3443399
5438157
4671727
6497108
5737669
4370929
6927686
4709671
7471554
5193399
5225523
5616839
5346407
6114430
5566901
7020607
5790779
5695537
6816066
6774678
7194547
42...

result:

ok 5500 lines

Test #115:

score: 0
Accepted
time: 91ms
memory: 4272kb

input:

5500 74 5500
72 4720 329156619
23 2964 658110492
6 2490 937332651
25 731 41846570
25 4327 661612568
36 999 370377287
23 4211 256323737
57 4522 64623341
9 3952 772812651
53 5177 81911003
12 2441 37154544
63 1511 451900804
59 3619 234171755
61 2898 662637246
46 3273 411268317
10 3126 176064999
35 2997...

output:

0
744736530
745568993
743802983
744255588
745061614
744521890
743687510
745656324
744515435
744919458
743256268
744144071
743487281
745091037
744562070
743352277
741847906
744280472
745632348
743682675
744488701
743081530
745006197
743367919
741649353
744296269
741584801
745460415
744853514
74650829...

result:

ok 5500 lines

Test #116:

score: 0
Accepted
time: 65ms
memory: 4476kb

input:

5500 5500 5496
3939 4549 259076815
5245 1226 826594909
1422 4699 633091014
2964 4182 828129159
5090 1288 241484819
681 913 761787227
3943 399 399259193
3757 3588 434353553
1337 4032 859374084
4950 4601 910282641
4704 747 234604539
419 4087 698526626
194 3453 658805129
3215 4922 870606338
285 3493 72...

output:

0
-1
4859025176928690
-1
2377422983763900
-1
7236448160692590
-1
4754845967527800
-1
2273243774363010
-1
7132268951291700
-1
4650666758126910
-1
2169064564962120
-1
7028089741890810
-1
4546487548726020
-1
2064885355561230
-1
6923910532489920
-1
4442308339325130
-1
1960706146160340
-1
681973132308903...

result:

ok 5496 lines

Test #117:

score: 0
Accepted
time: 85ms
memory: 4268kb

input:

5455 2750 5495
2453 1267 176564714
804 644 13517009
999 4160 568698599
2546 1114 724030971
118 5453 954109335
1450 5202 290234373
1113 898 586212846
2242 3017 150945386
2001 390 89509417
1237 5286 145871157
1670 1517 636163074
1330 4535 122650863
931 1224 108813488
481 752 752283154
2258 3061 337311...

output:

0
937097667355
937098068141
937096124358
937095597409
937097071767
937095969954
937098041877
937095737337
937096007110
937095555149
937096439514
937097413158
937097319488
937097205334
937095414856
937096625373
937098235438
937095789069
937094212403
937096612842
937097062892
937093690882
937096618586...

result:

ok 5495 lines

Test #118:

score: 0
Accepted
time: 91ms
memory: 4276kb

input:

5500 1375 5500
496 573 212283099
244 431 662575128
80 2629 29323396
1363 2212 843070441
1031 4431 380896793
146 4072 247704144
744 414 858104228
1289 4404 112153928
279 4552 356401383
362 1433 752962075
1338 4938 229045572
851 2008 144627814
957 3247 268843217
423 3684 844643832
145 643 882487631
23...

output:

0
293384072123
293382046204
293384376023
293384469830
293383520294
293383073534
293382434832
293383479416
293383133563
293381805719
293384865147
293384418387
293384391064
293383501195
293384545779
293384039852
293384787898
293384472122
293384309642
293385354226
293382984829
293383466554
293382282930...

result:

ok 5500 lines

Test #119:

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

input:

5500 550 5500
158 4137 342106733
300 2335 335843913
528 968 919086267
188 981 615235032
419 2163 241658955
485 1900 608416067
471 1494 504029526
519 3660 436593372
316 511 69702193
268 3662 942234183
84 5298 625511009
368 2350 370814813
131 1342 545888899
261 3614 967379396
413 3094 198496721
332 27...

output:

0
48382884729
48383872869
48383585522
48381450976
48383226870
48384666463
48383215070
48382376130
48383952369
48384102646
48383570848
48384161066
48383536861
48384142644
48384236010
48383190512
48382783340
48381046261
48382944831
48384072921
48382782569
48381511078
48383512866
48383947538
4838028440...

result:

ok 5500 lines

Test #120:

score: 0
Accepted
time: 38ms
memory: 4496kb

input:

5500 5500 5500
5159 2526 219666289
2024 1290 367155193
1980 73 18854157
2613 445 729385820
1666 4821 516915506
4406 3590 356625512
1835 2662 974843294
4621 332 684951603
4887 1591 804253981
2978 1762 78565495
4390 431 290338620
4838 1947 521271461
1516 1618 522992948
1480 23 906379452
2885 5174 1835...

output:

0
-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
-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
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-...

result:

ok 5500 lines

Test #121:

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

input:

5500 5500 5500
4691 36 397344029
1719 5043 627007667
1602 1272 255916044
624 1868 107361547
2932 2277 310500744
2615 4571 441132935
1424 773 133434972
3373 149 782310586
3775 4311 979066399
3978 4897 42378169
600 3357 503305984
1674 2362 75972252
2263 2399 280324390
5087 665 376276181
5304 430 22725...

output:

0
14350545652347954
14269202277832908
14187858903317862
14106515528802816
14025172154287770
13943828779772724
13862485405257678
13781142030742632
13699798656227586
13618455281712540
13537111907197494
13455768532682448
13374425158167402
13293081783652356
13211738409137310
13130395034622264
1304905166...

result:

ok 5500 lines

Test #122:

score: 0
Accepted
time: 78ms
memory: 4412kb

input:

5500 5499 5500
5106 5500 1000000000
667 5500 1000000000
1948 5500 1000000000
5109 5500 1000000000
3512 5500 1000000000
1337 5500 1000000000
3806 5500 1000000000
1500 5500 1000000000
211 5500 1000000000
5448 5500 1000000000
4166 5500 1000000000
2806 5500 1000000000
2679 5500 1000000000
2393 5500 1000...

output:

0
5499000000000
10998000000000
16497000000000
21996000000000
27495000000000
32994000000000
38493000000000
43992000000000
49491000000000
54990000000000
60489000000000
65988000000000
71487000000000
76986000000000
82485000000000
87984000000000
93483000000000
98982000000000
104481000000000
1099800000000...

result:

ok 5500 lines

Test #123:

score: 0
Accepted
time: 54ms
memory: 4396kb

input:

5500 5470 5499
1129 3046 27
2669 5198 118
1701 3616 155
1262 4938 156
5163 1974 39
4981 2075 284
5094 2798 153
2507 3442 42
4861 95 81
4312 3805 54
1782 5220 183
1164 1106 203
2782 1754 202
2631 837 237
2970 1583 40
1524 3214 132
720 775 143
4903 432 227
419 3905 289
260 757 121
2192 2270 158
4859 2...

output:

0
-1
-1
129557060
-1
-1
259114120
-1
-1
388671180
-1
-1
518228240
-1
-1
647785300
-1
-1
777342360
-1
-1
906899420
-1
-1
1036456480
-1
-1
1166013540
-1
-1
1295570600
-1
-1
1425127660
-1
-1
22568004
-1
-1
152125064
-1
-1
281682124
-1
-1
411239184
-1
-1
540796244
-1
-1
670353304
-1
-1
799910364
-1
-1
9...

result:

ok 5499 lines

Test #124:

score: 0
Accepted
time: 56ms
memory: 4224kb

input:

5500 2750 5500
2635 467 999998195
986 4596 999805575
1985 394 234
936 521 996529985
801 1222 270
235 5472 295
348 2481 998669485
11 3067 169
2409 2356 998196336
1266 5387 999975620
1915 4071 999995758
2591 4611 986153202
708 881 999788896
1517 4426 993080775
670 623 183
2551 883 999864297
1314 2813 ...

output:

0
-1
199557503
-1
399115006
-1
598672509
-1
798230012
-1
997787515
-1
70480268
-1
270037771
-1
469595274
-1
669152777
-1
868710280
-1
1068267783
-1
140960536
-1
340518039
-1
540075542
-1
739633045
-1
939190548
-1
11883301
-1
211440804
-1
410998307
-1
610555810
-1
810113313
-1
1009670816
-1
82363569
...

result:

ok 5500 lines

Test #125:

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

input:

5500 1833 5495
1540 754 981447607
661 2880 998832559
754 3510 999737776
1346 218 999482035
80 3579 999948075
386 4202 999768766
167 1236 999332257
14 687 109
29 4525 999955656
1145 1695 998422786
574 4631 221
564 1347 999934771
1146 4586 998064124
43 4224 113
939 1049 998989718
1792 1405 997462515
8...

output:

0
1012969113
517873941
22778769
1035747882
540652710
45557538
1058526651
563431479
68336307
1081305420
586210248
91115076
1104084189
608989017
113893845
1126862958
631767786
136672614
1149641727
654546555
159451383
1172420496
677325324
182230152
1195199265
700104093
205008921
1217978034
722882862
22...

result:

ok 5495 lines

Test #126:

score: 0
Accepted
time: 91ms
memory: 4512kb

input:

5500 5470 5500
2054 1166 330
4308 2402 857
3883 5288 1490
3708 2597 320
2525 453 1936
1890 5062 1822
2639 101 1243
415 1414 735
5309 2840 855
1308 2189 177
5272 614 151
3598 872 658
2832 2077 1136
5183 724 1481
3366 3797 380
931 3788 1721
183 3037 724
3290 1233 398
4086 3497 1458
2833 988 1976
1048 ...

output:

0
6328589739
12657179478
18985769217
25314358956
1349438195
7678027934
14006617673
20335207412
26663797151
2698876390
9027466129
15356055868
21684645607
28013235346
4048314585
10376904324
16705494063
23034083802
29362673541
5397752780
11726342519
18054932258
24383521997
418601236
6747190975
13075780...

result:

ok 5500 lines

Test #127:

score: 0
Accepted
time: 85ms
memory: 4296kb

input:

5500 2750 5500
867 60 926
797 2482 1398
1994 3176 997516547
1662 844 625
1176 5165 170
1718 173 665
930 3374 93
640 1093 998263067
2602 4109 997702574
2291 4387 311
1153 598 999967348
2071 333 999986842
1540 5091 1407
2233 1279 999924615
427 2592 999529715
255 1746 1162
323 3569 999016272
467 2501 9...

output:

0
12312661689
9362839878
6413018067
3463196256
513374445
12826036134
9876214323
6926392512
3976570701
1026748890
13339410579
10389588768
7439766957
4489945146
1540123335
13852785024
10902963213
7953141402
5003319591
2053497780
14366159469
11416337658
8466515847
5516694036
2566872225
14879533914
1192...

result:

ok 5500 lines

Test #128:

score: 0
Accepted
time: 85ms
memory: 4432kb

input:

5500 1833 5500
1025 174 999727079
491 1749 5
584 3475 998062342
17 2969 999603258
415 4646 998862198
97 2227 996259057
1575 2044 1534
444 1001 226
1174 3407 441
1189 1666 998880381
518 260 933474823
878 3358 998384917
1067 743 999985787
1334 1599 999963388
1317 4412 540
341 1343 988853636
783 1184 9...

output:

0
4721875949
9443751898
4056512347
8778388296
3391148745
8113024694
2725785143
7447661092
2060421541
6782297490
1395057939
6116933888
729694337
5451570286
64330735
4786206684
9508082633
4120843082
8842719031
3455479480
8177355429
2790115878
7511991827
2124752276
6846628225
1459388674
6181264623
7940...

result:

ok 5500 lines

Subtask #10:

score: 1
Accepted

Test #129:

score: 1
Accepted
time: 155ms
memory: 4252kb

input:

6915 1 7000
1 1363 798544346
1 1802 246549005
1 1408 140018720
1 5402 738500642
1 6888 49872332
1 3307 336638756
1 2652 17331455
1 457 771544741
1 564 615592335
1 1908 199704380
1 3914 669147974
1 1520 755888212
1 1451 710210708
1 4184 124275102
1 5351 604503666
1 2122 808958040
1 1877 73920823
1 48...

output:

0
6911499
5928926
3997819
5851792
3848083
6393120
5903789
5199180
5185462
6037842
5312175
5077169
5448940
4848774
5059064
5615845
5568674
5554164
6919305
2493738
4894718
4910358
4865237
5970050
5158196
4046051
6264687
5188378
6637651
6447045
4474238
3386619
4625646
5803239
4574493
6631451
5850498
49...

result:

ok 7000 lines

Test #130:

score: 0
Accepted
time: 147ms
memory: 4288kb

input:

7000 2 7000
1 1064 888492500
1 2253 175016336
1 583 501047782
2 1874 548316470
1 2347 858232118
2 4075 76821297
2 58 804989372
1 6067 578229970
1 1235 302714042
2 1304 877508602
2 3398 20540952
1 5037 454806929
1 1331 243494871
1 4358 131949302
2 79 453219159
1 3327 828298132
2 4858 85503401
2 4483 ...

output:

0
3272886
2889840
2617506
2691647
2308601
1925555
2439239
2056193
3271962
3072729
2689683
2306637
2050589
2508812
2967035
1862674
1479628
2385796
2976072
3203562
3260265
2691701
1860710
2766878
3197958
3383900
3000854
3072783
2626997
2446629
2586761
2998198
2585280
2202234
2631671
2954709
2665543
27...

result:

ok 7000 lines

Test #131:

score: 0
Accepted
time: 157ms
memory: 4280kb

input:

7000 4 7000
1 2773 449257617
3 4389 950338950
1 5744 1781387
2 5379 75852441
4 6518 47026047
4 2620 964045938
4 3316 751797563
1 1457 631430182
4 5948 421688940
2 3454 85085969
4 6777 315146391
3 5448 656663181
1 5757 916090594
1 3176 89184627
3 4184 672638368
3 2970 37356555
1 3488 554558603
1 3710...

output:

0
6702254
7565820
6037239
7799984
7295558
6812951
8546480
6485804
5950350
6979626
7964041
7322435
6543654
7572930
6755330
7915739
5696523
8246264
7348634
7584609
6289827
7394570
7832787
7133314
7372082
5047896
7250348
5390705
7593157
8095784
7843652
5984009
7237383
6906260
7748084
8466996
8088059
74...

result:

ok 7000 lines

Test #132:

score: 0
Accepted
time: 161ms
memory: 4372kb

input:

6744 83 6996
2 2149 726966835
5 4763 581041792
7 115 854398178
39 1864 250435418
30 4078 936381324
76 2124 35289899
25 3761 703243464
6 6624 495797124
19 745 455696618
59 6185 174360933
18 6267 258042545
74 2755 799464346
48 3728 972456572
69 6860 564332603
36 6565 584416884
13 1615 982221187
57 619...

output:

0
831888161
830260803
829554745
828296304
832178662
831122320
832334567
831875723
831807713
833383474
829696746
828438305
831049458
832764382
831761372
830738517
833051606
829882848
830386567
830155829
830703887
829859486
829791476
831367237
831011122
830943112
829992930
831339420
832110833
83114456...

result:

ok 6996 lines

Test #133:

score: 0
Accepted
time: 97ms
memory: 4632kb

input:

7000 7000 7000
5220 6669 18065942
3195 1475 278852894
6915 5827 806389237
6437 2136 365215583
1394 326 790914686
5284 2484 715423723
1376 3351 687766932
2748 2281 18429381
1381 1173 383524348
5010 6971 236520626
702 137 141327762
6968 6514 775314124
2664 5560 97629162
5463 1896 867487034
1281 2901 7...

output:

0
-1
3276845250812931
-1
6553690501625862
-1
9830535752438793
-1
1557573976217224
-1
4834419227030155
-1
8111264477843086
-1
11388109728656017
-1
3115147952434448
-1
6391993203247379
-1
9668838454060310
-1
1395876677838741
-1
4672721928651672
-1
7949567179464603
-1
11226412430277534
-1
2953450654055...

result:

ok 7000 lines

Test #134:

score: 0
Accepted
time: 164ms
memory: 4408kb

input:

7000 3500 7000
1338 2315 294721081
2207 4134 331701772
2922 3217 776671301
1755 5769 859529464
2645 3252 6684096
1338 5143 561847956
2420 5690 724243214
604 5716 354141118
265 865 618413547
206 6219 43654346
1194 6241 915599497
2247 584 491733620
1416 3333 760364683
1225 6558 825095752
3287 6158 762...

output:

0
1206723154842
1206722716038
1206722345098
1206723831706
1206722168053
1206722638505
1206722064513
1206721947564
1206724435678
1206723339815
1206722353676
1206722715256
1206723100529
1206722579278
1206723032131
1206723434115
1206720234715
1206722699813
1206722257520
1206721811020
1206724068147
1206...

result:

ok 7000 lines

Test #135:

score: 0
Accepted
time: 165ms
memory: 4356kb

input:

7000 1750 7000
971 1520 837790757
157 2696 837425022
39 6401 51073711
535 5691 208971948
146 6928 758268264
1600 4024 9348829
1104 1909 821804040
1327 6153 67497180
1200 4739 187727560
394 3419 616235114
1143 5438 926667186
83 3618 732549067
245 5516 685522518
1653 6275 149669746
756 1046 151345554
...

output:

0
362992871112
362994280608
362995088073
362993475679
362995840592
362993173097
362995956343
362994392221
362994760957
362994532395
362994332974
362992604248
362994092346
362992994977
362995107769
362994993507
362995823509
362995789309
362994154854
362994936849
362995929996
362995402260
362995473856...

result:

ok 7000 lines

Test #136:

score: 0
Accepted
time: 163ms
memory: 4256kb

input:

7000 700 7000
504 6751 802380948
159 4639 522211414
247 5623 918766863
373 5162 541904581
29 6269 96366982
44 6094 691364203
197 335 76297
3 721 738830196
52 3959 796870824
444 6660 406867858
693 4903 166381322
238 894 235539635
391 5927 126748548
298 2565 724651334
428 4788 40910412
239 4935 385178...

output:

0
59646455895
59646091431
59646058195
59647226424
59647223271
59645340687
59645437782
59646367203
59646988408
59646338228
59647269271
59646901805
59646551192
59646843318
59646706016
59645049073
59644479124
59647122555
59646192626
59646880562
59645807904
59646401403
59646575639
59646882879
5964702153...

result:

ok 7000 lines

Test #137:

score: 0
Accepted
time: 54ms
memory: 4388kb

input:

7000 7000 7000
2984 5400 726251218
6145 403 675038216
6705 3977 993643980
4353 6146 457454361
2888 3511 725537493
5264 4234 862051424
3466 4541 581077222
2916 2349 668410555
5983 6779 803012434
5380 3300 713500423
4384 3636 112717283
2869 5758 355542824
2609 2160 193452880
5294 1317 734305302
4994 6...

output:

0
-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
-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
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-...

result:

ok 7000 lines

Test #138:

score: 0
Accepted
time: 62ms
memory: 4504kb

input:

7000 7000 7000
6376 1538 105092989
465 746 129907762
251 5915 233573161
5598 379 88148951
1589 4881 164177172
6625 88 46169025
6816 5932 948554864
1982 1585 361037049
6965 6312 30410366
4638 1879 32065551
5094 3584 417733213
3178 2550 454012519
5543 1873 55995297
2860 1776 457957940
5112 5684 160564...

output:

0
-1
-1
-1
-1
-1
-1
-1
2786509437787712
-1
-1
-1
-1
-1
-1
-1
2642495127902049
-1
-1
-1
-1
-1
-1
-1
2498480818016386
-1
-1
-1
-1
-1
-1
-1
2354466508130723
-1
-1
-1
-1
-1
-1
-1
2210452198245060
-1
-1
-1
-1
-1
-1
-1
2066437888359397
-1
-1
-1
-1
-1
-1
-1
1922423578473734
-1
-1
-1
-1
-1
-1
-1
17784092685...

result:

ok 7000 lines

Test #139:

score: 0
Accepted
time: 125ms
memory: 4564kb

input:

7000 6999 7000
1402 7000 1000000000
491 7000 1000000000
5378 7000 1000000000
2421 7000 1000000000
5457 7000 1000000000
6858 7000 1000000000
2439 7000 1000000000
78 7000 1000000000
2234 7000 1000000000
6257 7000 1000000000
2620 7000 1000000000
3614 7000 1000000000
5851 7000 1000000000
3021 7000 10000...

output:

0
6999000000000
13998000000000
20997000000000
27996000000000
34995000000000
41994000000000
48993000000000
55992000000000
62991000000000
69990000000000
76989000000000
83988000000000
90987000000000
97986000000000
104985000000000
111984000000000
118983000000000
125982000000000
132981000000000
139980000...

result:

ok 7000 lines

Test #140:

score: 0
Accepted
time: 136ms
memory: 4516kb

input:

7000 6970 7000
247 4865 276
1137 2071 995998260
515 4690 293
1203 3492 267
1493 5114 213
418 4147 277
3104 3993 264
4306 6304 150
1716 4236 130
6360 851 215
5946 6615 82
2135 4119 88
168 4910 154
4463 6682 87
2422 5607 224
2639 3963 67
2069 1899 156
4555 3372 165
3872 1291 66
3075 189 226
3313 1892 ...

output:

0
2694634677
5389269354
712883031
3407517708
6102152385
1425766062
4120400739
6815035416
2138649093
4833283770
156897447
2851532124
5546166801
869780478
3564415155
6259049832
1582663509
4277298186
6971932863
2295546540
4990181217
313794894
3008429571
5703064248
1026677925
3721312602
6415947279
17395...

result:

ok 7000 lines

Test #141:

score: 0
Accepted
time: 135ms
memory: 4328kb

input:

7000 3500 6999
2097 3183 34
2197 1534 999672991
188 4704 999929815
1429 3339 996566166
664 6958 297
2614 3762 998608203
1984 1843 999112830
2233 1171 995256481
110 5794 236
586 5374 999987743
1994 80 999991368
2475 6281 11
2985 3869 298
3141 32 84
2348 4198 271
2416 6866 994390320
2752 5013 63
3351 ...

output:

0
847297230
1694594460
2541891690
3389188920
532405380
1379702610
2226999840
3074297070
217513530
1064810760
1912107990
2759405220
3606702450
749918910
1597216140
2444513370
3291810600
435027060
1282324290
2129621520
2976918750
120135210
967432440
1814729670
2662026900
3509324130
652540590
149983782...

result:

ok 6999 lines

Test #142:

score: 0
Accepted
time: 76ms
memory: 4296kb

input:

7000 2333 6999
1027 5703 993202196
722 2351 998476124
1673 531 28
230 2423 991874525
338 2696 999994671
1620 2277 999610220
1329 3091 998450178
649 6055 999971496
1675 26 998804009
1409 4935 999974977
1082 726 999921114
1243 4872 63
472 278 995722865
1845 4923 999842398
1708 4950 140
1047 66 9839576...

output:

0
-1
-1
156570084
-1
-1
313140168
-1
-1
469710252
-1
-1
626280336
-1
-1
782850420
-1
-1
120411522
-1
-1
276981606
-1
-1
433551690
-1
-1
590121774
-1
-1
746691858
-1
-1
84252960
-1
-1
240823044
-1
-1
397393128
-1
-1
553963212
-1
-1
710533296
-1
-1
48094398
-1
-1
204664482
-1
-1
361234566
-1
-1
517804...

result:

ok 6999 lines

Test #143:

score: 0
Accepted
time: 137ms
memory: 4552kb

input:

7000 6970 6997
63 113 620
4422 5899 1547
6132 35 204
5430 1369 1074
4373 2920 1518
5625 4148 1059
1951 5096 1472
6756 2099 465
5736 6965 636
533 3872 594
5398 5946 269
6771 5954 27
4419 5402 31
4923 535 444
2534 6766 731
2726 3302 1489
2024 5797 690
5991 5676 1957
1203 3786 1287
1682 6085 1188
4049 ...

output:

0
12551247434
25102494868
37653742302
1225024150
13776271584
26327519018
38878766452
2450048300
15001295734
27552543168
40103790602
3675072450
16226319884
28777567318
41328814752
4900096600
17451344034
30002591468
42553838902
6125120750
18676368184
31227615618
43778863052
7350144900
19901392334
3245...

result:

ok 6997 lines

Test #144:

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

input:

7000 3500 7000
2381 5013 998790922
2847 1172 1677
120 1219 999939203
562 1441 1135
2521 6138 99
1120 6501 1564
1135 4039 921
434 6653 765
671 1234 999686654
473 5938 999714742
2853 5987 946708614
2338 2268 999847583
1756 2818 1458
2953 2288 999663576
398 4763 981726553
3470 1755 999486386
538 2591 1...

output:

0
-1
4664657421
-1
9329314842
-1
1980505763
-1
6645163184
-1
11309820605
-1
3961011526
-1
8625668947
-1
1276859868
-1
5941517289
-1
10606174710
-1
3257365631
-1
7922023052
-1
573213973
-1
5237871394
-1
9902528815
-1
2553719736
-1
7218377157
-1
11883034578
-1
4534225499
-1
9198882920
-1
1850073841
-1...

result:

ok 7000 lines

Test #145:

score: 0
Accepted
time: 65ms
memory: 4368kb

input:

7000 2333 6996
628 5247 999944174
1496 2501 991132611
428 6790 999999932
1131 1753 995757342
941 4220 994895062
230 5164 991413822
2196 369 999954948
611 1065 998300582
1857 6902 364
1211 4481 663
2205 4291 999898939
1711 6164 979759084
2201 318 103
1544 3852 982051901
1731 4202 992630937
370 2983 4...

output:

0
-1
-1
-1
222869864
-1
-1
-1
445739728
-1
-1
-1
668609592
-1
-1
-1
891479456
-1
-1
-1
1114349320
-1
-1
-1
1337219184
-1
-1
-1
1560089048
-1
-1
-1
1782958912
-1
-1
-1
2005828776
-1
-1
-1
2228698640
-1
-1
-1
2451568504
-1
-1
-1
2674438368
-1
-1
-1
2897308232
-1
-1
-1
3120178096
-1
-1
-1
3343047960
-1...

result:

ok 6996 lines

Test #146:

score: 0
Accepted
time: 41ms
memory: 4296kb

input:

7000 777 7000
121 2753 273617338
390 37 879979155
227 5617 122995943
224 2755 285863736
417 6936 461654381
162 4154 896312606
294 2768 488985740
531 1429 382302193
734 5634 115187071
581 4223 810485492
460 1499 22645648
220 33 466307822
452 5573 464093405
667 5540 683997078
179 5639 117140424
258 13...

output:

0
-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
-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
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-...

result:

ok 7000 lines

Test #147:

score: 0
Accepted
time: 42ms
memory: 4296kb

input:

7000 1166 7000
690 41 735362879
739 6915 197897018
119 6864 195208269
1114 95 794895406
628 176 506194332
345 7 97161359
492 6938 109061639
861 6858 56872775
582 6984 891547769
466 82 307230989
147 44 169391003
1031 6913 15884512
637 226 58578885
720 6911 500089181
435 6997 26971066
1122 6981 469089...

output:

0
-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
-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
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-...

result:

ok 7000 lines

Test #148:

score: 0
Accepted
time: 140ms
memory: 4480kb

input:

7000 7000 7000
1 4251 1000000000
2 963 1000000000
3 1494 1000000000
4 4103 1000000000
5 2009 1000000000
6 4774 1000000000
7 759 1000000000
8 5124 1000000000
9 4899 1000000000
10 3418 1000000000
11 3468 1000000000
12 976 1000000000
13 6475 1000000000
14 174 1000000000
15 19 1000000000
16 4934 1000000...

output:

0
42511000000000000
36022000000000000
29533000000000000
23044000000000000
16555000000000000
10066000000000000
3577000000000000
46088000000000000
39599000000000000
33110000000000000
26621000000000000
20132000000000000
13643000000000000
7154000000000000
665000000000000
43176000000000000
36687000000000...

result:

ok 7000 lines

Extra Test:

score: 0
Extra Test Passed