QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#32156#1454. Um nik's AlgorithmWu_RenAC ✓3322ms132204kbC++112.5kb2022-05-17 21:33:022022-05-17 21:33:02

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-17 21:33:02]
  • 评测
  • 测评结果:AC
  • 用时:3322ms
  • 内存:132204kb
  • [2022-05-17 21:33:02]
  • 提交

answer

#include <bits/stdc++.h>
const int inf=2e9;
using namespace std;
mt19937 rng(time(0));
namespace io{
	const int SIZE = (1 << 24) + 1;
	char ibuf[SIZE], *iS, *iT;
	char obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55];
	int f, qr;
	
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	
	template <class I>
	inline void read (I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); 
		x = f == -1 ? -x : x;
	}
	
	template <class I>
	inline void print (I x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io :: read;
using io :: putc;
using io :: print;
int n,m,e,head[2000010],o=0,L[2000010],R[2000010],Ld[2000010],Rd[2000010],Lid[2000010];
bool vis[2000010];
struct edge{
	int to,link;
}E[2000010];
queue<int>q;
void add_edge(int u,int v){
	E[++o]={v,head[u]},head[u]=o;
}
bool bfs(){
	fill(Ld+1,Ld+n+1,0);
	fill(Rd+1,Rd+m+1,0);
	while(q.size()) q.pop();
	for(int i=1;i<=n;i++) if(!L[i]) q.push(i),Ld[i]=1;
	int dis=inf;
	while(q.size()){
		int u=q.front();q.pop();
		if(Ld[u]>dis) break;
		for(int i=head[u],v;i;i=E[i].link) if(!Rd[v=E[i].to]){
			Rd[v]=Ld[u]+1;
			if(!R[v]) dis=Rd[v];
			else{
				Ld[R[v]]=Rd[v]+1,q.push(R[v]);
			}
		}
	}
	return dis<inf;
}
bool dfs(int u){
	for(int i=head[u];i;i=E[i].link){
		int v=E[i].to;
		if(!vis[v]&&Rd[v]==Ld[u]+1){
			vis[v]=1;
			if(R[v]&&Rd[v]==inf) continue;
			if(!R[v]||dfs(R[v])){
				L[R[v]=u]=v;
				Lid[u]=i;
				return 1;
			}
		}
	}
	return 0;
}
int u[2000010],v[2000010],p[2000010];
int main(){
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	read(n),read(m),read(e);
	iota(p+1,p+e+1,1),shuffle(p+1,p+e+1,rng);
	for(int i=1;i<=e;i++) read(u[i]),read(v[i]);
	for(int i=1;i<=e;i++){
		E[p[i]]={v[p[i]],head[u[p[i]]]},head[u[p[i]]]=p[i];
	}
	int ans=0;
	for(int _=0;(double)clock()/CLOCKS_PER_SEC<3.0&&_<19&&bfs();_++){
		fill(vis+1,vis+m+1,0);
		for(int i=1;i<=n;i++) if(!L[i]&&dfs(i)) ans++;
	}
	print(ans),putc('\n');
	for(int i=1;i<=n;i++) if(Lid[i]) print(Lid[i]),putc('\n');
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 5660kb

input:

3 2 4
1 1
2 1
3 1
3 2

output:

2
1
4

result:

ok answer: 2, maximum: 2

Test #2:

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

input:

20 20 20
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
11 11
12 12
13 13
14 14
15 15
16 16
17 17
18 18
19 19
20 20

output:

20
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

result:

ok answer: 20, maximum: 20

Test #3:

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

input:

1000 1000 10000
988 405
844 805
40 354
416 591
520 704
697 24
315 386
122 390
991 213
506 14
309 298
26 829
329 63
787 91
971 703
805 699
624 645
121 181
841 741
473 84
258 116
490 753
725 603
265 302
869 71
611 507
59 292
11 532
117 61
192 600
650 342
204 580
687 675
670 407
637 622
569 236
728 476...

output:

1000
360
846
2891
8889
137
819
4377
2426
6428
1940
3928
2015
3949
6081
7440
2738
8096
5621
8440
8431
6564
4213
3860
582
7483
1409
1332
6940
6882
3797
4028
2718
5479
5058
7884
8951
9610
4490
3028
4893
9574
1888
4660
4707
6683
7695
7789
2927
2285
8528
2907
6070
1759
4666
9301
603
9714
7575
4462
3376
3...

result:

ok answer: 1000, maximum: 1000

Test #4:

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

input:

100 2 200
40 1
22 2
75 2
79 1
27 2
11 1
7 1
64 1
21 1
57 2
47 1
4 2
61 2
37 1
8 2
32 2
84 1
63 1
67 1
86 2
88 2
73 1
17 1
94 2
44 2
19 2
16 1
33 2
92 1
24 2
100 2
18 2
85 1
7 2
43 1
82 2
15 2
88 1
91 1
65 1
69 1
36 1
6 2
23 2
58 1
59 1
64 2
38 1
72 1
99 1
76 1
11 2
2 2
98 1
66 2
77 1
47 2
98 2
52 2
...

output:

2
191
53

result:

ok answer: 2, maximum: 2

Test #5:

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

input:

1000 1000 1000
411 789
753 186
495 203
417 324
490 424
195 480
314 23
663 218
12 747
124 390
134 38
218 536
291 840
174 908
474 767
313 167
575 9
857 427
313 27
959 935
258 70
472 957
747 228
205 939
293 303
626 802
712 283
658 346
208 383
889 204
99 640
801 966
828 742
534 11
259 734
226 129
843 35...

output:

540
384
183
146
154
674
274
96
242
490
642
735
97
806
995
694
464
848
443
186
199
610
188
137
738
207
493
737
91
222
342
597
38
449
434
201
318
725
401
393
774
42
269
446
408
827
127
500
59
410
335
959
257
628
190
932
492
771
624
474
258
108
233
244
374
49
307
788
846
862
212
847
898
115
66
911
564
...

result:

ok answer: 540, maximum: 540

Test #6:

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

input:

1000 2000 3000
143 619
571 526
215 1074
6 1714
370 937
120 784
134 1671
722 1528
397 345
464 401
198 589
283 564
212 232
527 286
237 1649
413 1570
964 1731
194 645
639 735
182 656
641 1143
535 98
113 596
787 972
306 818
657 1202
321 1327
753 1088
122 1823
471 611
516 811
380 1548
872 973
509 1841
70...

output:

944
2279
2715
1674
1101
1838
820
620
770
1743
2377
1188
2663
1639
1826
1804
1828
2461
2866
2567
2274
91
1499
642
1268
1812
804
1293
625
376
1677
805
2067
2954
773
2539
2183
1020
876
213
2368
2677
1322
1596
1147
1907
1836
2158
1364
2623
663
2301
908
116
1898
2776
1908
490
2656
686
187
638
1043
2560
1...

result:

ok answer: 944, maximum: 944

Test #7:

score: 0
Accepted
time: 3161ms
memory: 119348kb

input:

2000000 2000000 2000000
1203137 1030076
215220 238101
293102 491863
1260446 165178
1683989 1718181
1641329 1179380
708733 403707
1918936 574923
525651 11571
1169951 422281
1086376 303530
1286459 1692862
31854 394688
916288 273853
709758 1176923
1730408 1766172
1890708 588004
344339 283448
1676753 13...

output:

1088263
344661
1553819
776789
25588
390185
1869689
1734380
1963415
675162
1392530
385807
713135
1274732
788512
1100762
1838272
1499360
1345142
1913484
846827
209862
131076
1679462
786983
1086102
1286200
39246
644591
1117195
72900
704242
1816427
583683
1586107
1917639
1520861
598151
447735
405150
143...

result:

ok answer: 1088263, maximum: 1088264

Test #8:

score: 0
Accepted
time: 2971ms
memory: 119468kb

input:

2000000 2000000 2000000
1286561 1611624
1028477 1867578
1642356 1162128
1032429 316462
618144 22363
1644873 1514932
508824 1230141
1889259 22840
30270 259129
1567969 462330
150124 1227115
393968 534541
1378415 770304
977805 1666010
1199878 1476793
1249634 243739
1232999 531436
1146447 1845344
478779...

output:

1088046
810120
497810
504383
1351756
588666
1910815
885219
1791117
302655
1888666
166581
535493
44165
1515178
193880
1907290
1648404
1406469
493201
1425814
438087
20030
1371613
704734
510907
82104
1786792
550474
377030
1495370
1213942
1381872
571460
248994
528203
295501
750793
799606
380887
1850255
...

result:

ok answer: 1088046, maximum: 1088048

Test #9:

score: 0
Accepted
time: 3125ms
memory: 119452kb

input:

2000000 2000000 2000000
402689 127765
1065927 1753952
991609 1640904
1061308 533154
1552300 326545
1905312 1074675
1084722 1799678
51070 1470757
310696 763584
1965988 759275
246577 1374893
277285 408924
1692272 1856320
72026 1123575
1881487 1519767
1993052 1562521
575291 1507572
205452 248456
134621...

output:

1087917
837953
1331291
965101
770875
820425
731776
1618490
376606
967371
904538
96689
1994239
1720093
1518641
463705
1239453
1500777
1531316
807103
3531
1196425
905866
625664
24927
1795764
444677
1047395
435404
572254
1552982
1695776
653004
921030
332441
1646823
357998
199747
870143
776153
1233141
1...

result:

ok answer: 1087917, maximum: 1087919

Test #10:

score: 0
Accepted
time: 3199ms
memory: 119488kb

input:

2000000 2000000 2000000
486113 452417
846481 1383429
1116671 119681
1800588 1717142
294967 630728
1198456 1601715
884812 626111
1054097 142866
782611 1978438
1396710 1832027
534517 555375
417499 1250604
6129 166529
1166247 772627
371607 1819638
1512279 1072791
884878 1451005
1974857 843056
213647 10...

output:

1088038
550867
39093
1328189
1724622
1271816
1548099
1468045
859800
514002
1916395
914727
605099
1342629
1715388
1185050
319989
1744920
1300369
855810
542412
1746
24927
1792257
1765880
1700433
1711390
1440610
732877
1118675
1125721
1639922
104325
370171
1485731
1655910
415341
258442
1077051
824470
7...

result:

ok answer: 1088038, maximum: 1088039

Test #11:

score: 0
Accepted
time: 2975ms
memory: 119060kb

input:

2000000 2000000 2000000
569537 968557
1851226 45611
465925 789946
605275 1868426
261827 934910
1458895 1161459
684902 1195648
1215908 623487
30333 482892
827432 1096268
1598266 1478961
1525008 349179
385394 476737
1227764 164784
85919 119508
255697 326166
1970273 1394437
1809670 1180760
1015672 2547...

output:

1088081
968620
1852251
1611625
457420
1886309
384561
980986
952925
1682882
1462004
261888
292671
1096461
1385844
1366662
785234
967619
448903
1073713
1155785
978065
1739948
123600
428347
142989
740394
711182
904204
662826
1195670
1773563
1671916
235370
1508576
30559
659990
742806
1508744
1982740
177...

result:

ok answer: 1088081, maximum: 1088084

Test #12:

score: 0
Accepted
time: 3196ms
memory: 119384kb

input:

2000000 2000000 2000000
1685665 517402
664484 1675089
782474 1268723
1601450 85118
1195982 1239092
752039 721202
484993 1054786
218935 71404
310760 730450
1225450 1393213
662014 594034
632517 223562
699251 595457
321985 846541
576040 1386674
1774923 1836436
1312564 1337869
868675 808065
1107298 1517...

output:

1087210
1728405
881214
1567679
208184
1688537
405113
1889230
500980
271637
1885809
1067703
285974
125651
1659446
1434211
407464
1450198
1903568
153864
1880417
713480
1436324
167454
287327
1522861
1029956
162659
949482
260650
699165
498965
984199
653834
1232576
1837643
1645999
709761
104406
1552913
1...

result:

ok answer: 1087210, maximum: 1087210

Test #13:

score: 0
Accepted
time: 2366ms
memory: 120952kb

input:

2000000 2000000 2000000
671367 438853
664485 1398539
742842 386640
982299 485454
546419 1461681
1152709 654964
1250048 1661588
622998 536507
189300 1149326
1931736 1799077
327683 1819025
1040667 1571337
868282 1226836
498815 773984
808618 988294
712394 173925
134058 436291
98285 443781
1609589 78910...

output:

1535209
1120556
1423199
384989
598957
523457
1714883
56865
1080774
743400
260739
1755097
1993518
440113
1190137
744384
97424
572535
1441382
445740
613400
228510
1154754
1561363
135009
845678
714245
1023547
1045159
1259514
676272
1867622
1793696
1010277
292729
731184
1087628
977833
517452
886367
1533...

result:

ok answer: 1535209, maximum: 1535209

Test #14:

score: 0
Accepted
time: 1825ms
memory: 121972kb

input:

2000000 2000000 2000000
138574 1342064
1643595 562587
1113082 1866381
1046781 69854
1995906 718620
1878456 1065477
1148129 1000230
128358 393159
1893827 365760
1922621 1583574
868735 553414
1400420 471921
147059 404788
1439120 680482
225083 1540271
1016807 1950769
1635754 371279
967724 1695575
13292...

output:

1802113
6362
1339423
60115
1999121
820864
696167
709041
1396160
868571
1322619
940568
1529006
1549445
514474
1343837
1949865
1108408
835048
1840966
234042
13142
1750442
409270
772698
1547917
366449
1178431
1194409
936462
1105293
1977808
620731
1105901
1412166
91471
504162
386533
654067
110586
164378...

result:

ok answer: 1802113, maximum: 1802113

Test #15:

score: 0
Accepted
time: 1699ms
memory: 123544kb

input:

2000000 2000000 2000000
536222 1734576
23820 45248
833336 1030570
413414 1449610
1303634 31529
1081756 593258
988649 183711
216216 1083600
127109 1327665
1021151 187582
712397 68980
1201276 912972
579821 1496356
516811 165481
829561 433889
116397 1703535
41995 1565188
452103 1023063
124730 1958243
2...

output:

1900296
958576
1740016
1161117
644631
280340
827347
1807781
1203534
1147968
383576
1741395
1542944
446365
114091
1278666
1593112
635550
1142718
1589809
1172424
1632521
653844
1741658
1939044
490864
1775919
1340062
1457210
297170
880035
1397755
1060445
989419
1393719
247031
1426183
392411
1652066
145...

result:

ok answer: 1900296, maximum: 1900296

Test #16:

score: 0
Accepted
time: 1610ms
memory: 130644kb

input:

2000000 2000000 2000000
722296 810199
1104653 1326072
1384593 1991732
1359998 1074298
1745667 1702626
1958690 1040248
741056 1119935
123334 480039
941370 1134989
1340612 1877995
1628998 735318
1713870 573904
179004 731624
244572 1375222
1938456 934124
429528 1129329
655320 133186
1680525 1039251
180...

output:

1999999
1285010
1756744
1643939
968675
69977
96998
497277
1152546
387546
1401359
1672824
381286
46277
634809
1963762
881477
1302540
1331047
634583
1512173
1276602
599004
1733509
478730
767881
220076
791736
797263
1954887
1728713
382149
62362
334218
948178
1615066
1479842
463419
427277
242773
1261507...

result:

ok answer: 1999999, maximum: 1999999

Test #17:

score: 0
Accepted
time: 795ms
memory: 94908kb

input:

2000000 2000000 2000000
1047606 1292677
12506 1323616
1342868 93241
104701 1762734
1092674 826296
832718 320225
1030367 1004288
1092277 1855541
1147594 1592403
344053 1265006
957034 1327349
1581922 1471180
1394689 1275806
347140 757111
1968638 1065864
1735165 801763
916090 1855541
1294013 117591
177...

output:

38
597961
1587516
549914
1826967
801078
1093525
1572595
1958748
1111036
411326
117908
628049
1706908
1491628
1609938
480387
1802238
519318
171417
6901
792289
41203
1730447
1368145
1767575
1950488
1132420
1832088
1414217
862673
186912
19808
1279064
289700
699973
495209
739202
1116309

result:

ok answer: 38, maximum: 38

Test #18:

score: 0
Accepted
time: 749ms
memory: 94672kb

input:

2000000 2000000 2000000
1873411 1383547
592374 1383547
837927 228335
880140 1383547
117684 1383547
873521 1383547
1659145 1383547
837927 1940103
684954 1383547
837927 649822
837927 553974
837927 263980
837927 1851187
645118 1383547
837927 536305
1931765 1383547
960556 1383547
837927 741946
837927 18...

output:

2
804866
1558655

result:

ok answer: 2, maximum: 2

Test #19:

score: 0
Accepted
time: 742ms
memory: 94496kb

input:

2000000 2000000 2000000
679516 1758922
654113 491405
679516 903481
679516 1931142
1695416 491405
1087335 491405
679516 209225
991588 491405
679516 1423758
679516 1731533
815888 491405
84804 491405
679516 614525
532920 491405
679516 1583057
852179 491405
679516 641320
679516 158707
679516 883286
6795...

output:

2
1086722
931772

result:

ok answer: 2, maximum: 2

Test #20:

score: 0
Accepted
time: 824ms
memory: 97888kb

input:

2000000 2000000 2000000
950672 1358549
1019276 293
1341818 453182
517288 976497
1157473 567426
1601935 896019
1434229 1234860
1822883 1319667
1174043 794189
815886 186003
1433841 238760
599172 90292
1139073 538283
1651444 1723218
1890294 90292
749958 1255878
1584651 934604
31690 1957346
582723 18920...

output:

444
964839
1919671
92960
1906792
1345433
1724449
1774093
1064010
551302
968745
1993970
1432834
1958146
1876258
586250
1050943
874819
533816
533161
1787014
1400024
665482
1950010
405143
1287234
872898
1749447
530984
659415
803143
575552
1946726
169737
983062
1079306
1845066
1868718
1858079
1272343
19...

result:

ok answer: 444, maximum: 444

Test #21:

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

input:

32 32 768
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
2 1
2 2
2 3
2 4
2 5
2 6
2 7
2 8
2 9
2 10
2 11
2 12
2 13
2 14
2 15
2 16
2 17
2 18
2 19
2 20
2 21
2 22
2 23
2 24
2 25
2 26
2 27
2 28
2 29
2 3...

output:

32
28
56
84
118
145
192
213
253
286
306
346
383
407
443
467
505
517
544
552
573
587
593
623
634
647
660
678
690
713
723
750
764

result:

ok answer: 32, maximum: 32

Test #22:

score: 0
Accepted
time: 387ms
memory: 61900kb

input:

1632 1632 1997568
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1...

output:

1632
1308
3149
4321
5965
7589
9770
11187
12385
13954
15807
17515
19022
20432
22284
23883
26032
27692
29040
30233
32034
34025
35379
36929
38633
40369
41810
43895
45460
47108
48704
50191
51470
53307
55342
56551
58029
59857
61706
63006
64802
66609
68376
69416
71073
72848
74522
76122
77741
79238
80790
8...

result:

ok answer: 1632, maximum: 1632

Test #23:

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

input:

189 189 19845
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
...

output:

189
89
194
342
475
590
715
861
946
1132
1246
1344
1484
1605
1712
1836
1984
2139
2225
2350
2502
2631
2725
2852
3023
3131
3226
3380
3469
3606
3720
3893
3979
4153
4274
4372
4479
4637
4779
4907
5020
5132
5266
5357
5495
5625
5785
5910
6024
6143
6277
6370
6535
6623
6788
6930
7005
7155
7278
7395
7552
7651
...

result:

ok answer: 189, maximum: 189

Test #24:

score: 0
Accepted
time: 415ms
memory: 62816kb

input:

1896 1896 1997120
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1...

output:

1896
1060
2235
3381
4974
6101
7424
8509
9686
11016
12575
13499
15122
16354
17510
18802
19932
21346
22130
23807
24715
26037
27184
28706
30151
31480
32742
34105
35279
36388
37428
39146
39884
41125
42663
43903
45021
46333
47590
48918
49956
51502
52899
53834
55333
56719
57787
59109
60069
61520
63059
643...

result:

ok answer: 1896, maximum: 1896

Test #25:

score: 0
Accepted
time: 450ms
memory: 88636kb

input:

2000000 2000000 1997120
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
...

output:

1896
777
2345
3434
4966
6306
7298
8549
10027
11327
12208
13709
15021
15840
17393
18469
19644
21127
22251
23518
25008
25979
27292
29013
30211
31030
32710
33814
34834
36407
37909
39024
40161
41416
42515
43982
45383
46386
47492
49111
49936
51653
52976
54234
55156
56319
57618
59298
60368
61817
62977
640...

result:

ok answer: 1896, maximum: 1896

Test #26:

score: 0
Accepted
time: 597ms
memory: 117752kb

input:

2000000 2000000 2000000
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
...

output:

183937
833
2009
3513
4217
5833
6736
8194
9160
10685
11541
13173
14258
15468
16455
17611
18639
20213
21412
22432
23934
25189
25823
27151
28443
29954
30907
32375
33102
34656
35419
37088
38301
39036
40295
41948
42846
44139
45516
46752
47567
48824
49822
51179
52785
53821
55057
55863
57364
58770
59872
60...

result:

ok answer: 183937, maximum: 183937

Test #27:

score: 0
Accepted
time: 1129ms
memory: 117876kb

input:

2000000 2000000 2000000
513 1122
1458 523
325 794
1951215 1284660
33 326
361 381
967 990
554 329
1682 399
250 704
294 196
520 496
976 939
583 776
689 1048
163 262
884 889
1147 1673
1552 459
1097 1091
826436 1860
255 516
1640 446
1643 55
1028 1318
1307752 1431867
716 1405
264 671
1018 1511
1798 413
1...

output:

184175
320645
420858
1677010
1054598
664575
339163
1182851
926650
1883912
1454076
571056
928116
1007251
1811232
959220
570959
289782
708252
1946664
879406
1862094
518087
27275
53311
728063
1002125
1880534
1781828
269642
1930040
1419586
1721488
973970
1982069
695090
253611
1848970
437334
187226
64080...

result:

ok answer: 184175, maximum: 184175

Test #28:

score: 0
Accepted
time: 610ms
memory: 117800kb

input:

2000000 2000000 2000000
318377 264230
318377 297294
318377 1168121
318377 1168378
318377 687841
318377 317579
318377 1045281
318377 193774
318377 1286449
318377 809491
318377 305478
318377 1431410
318377 173240
318377 1833841
318377 824344
318377 722522
318377 1887702
318377 1302344
318377 864333
31...

output:

183975
1913906
1985118
1828617
1896679
1880067
1903659
1987606
1833507
1929104
1941361
1996736
1855514
1984261
1969107
1872394
1767295
1965518
1905161
1918451
1886351
1990278
1998329
1830788
1958757
1967911
1809744
1972585
1958276
1977838
1828908
1972495
1928778
1942049
1851160
1998897
1931620
18705...

result:

ok answer: 183975, maximum: 183975

Test #29:

score: 0
Accepted
time: 1270ms
memory: 117776kb

input:

2000000 2000000 2000000
1625116 599613
539469 1308455
812983 176633
874289 461823
1824953 1589033
794027 1271010
178174 1700721
1161616 1322163
1277276 32631
1962706 1017199
282239 1158238
1206051 966351
1745846 987176
361370 985866
857047 470035
637002 976591
1362011 429199
1160438 673497
1007777 1...

output:

184156
1205010
1530636
1737798
85437
799870
506532
1377956
1258161
239954
1989647
1208217
364421
625964
40586
1284320
961337
866873
1329027
747244
1708892
1152785
13956
1623245
1921339
1989871
1277660
1461252
1686614
715771
879062
415638
564211
905208
588946
784603
427466
1627499
1760199
693713
5494...

result:

ok answer: 184156, maximum: 184156

Test #30:

score: 0
Accepted
time: 477ms
memory: 117612kb

input:

2000000 2000000 2000000
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
...

output:

11043
662
2168
3366
4588
5869
7083
8349
9956
11167
12186
13825
14540
15790
17256
18680
20140
21315
22384
23909
24957
26439
27293
28683
30060
31326
32791
33567
35293
36445
37485
38857
39905
41043
42902
43889
45270
46455
47627
49082
50339
51285
52636
53944
55002
56372
57517
58978
60568
61565
62843
640...

result:

ok answer: 11043, maximum: 11043

Test #31:

score: 0
Accepted
time: 443ms
memory: 111364kb

input:

2000000 2000000 2000000
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
...

output:

4770
1071
2224
3791
4464
5765
7077
8431
10058
10996
12044
13754
15041
16382
17455
18560
19710
21274
22265
23441
25228
26352
27459
28498
30178
31536
32615
34033
34937
36278
37647
38942
40369
41558
42373
43776
45469
46717
47711
48933
49962
51766
52966
54065
55573
56633
57745
59321
60549
61323
62962
64...

result:

ok answer: 4770, maximum: 4770

Test #32:

score: 0
Accepted
time: 608ms
memory: 94604kb

input:

2000000 2000000 2000000
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
...

output:

1505
972
1513
2560
3719
4786
5755
6708
7665
8695
9956
10577
11607
12875
13675
14888
15632
16614
17606
18905
19662
20733
21565
22667
23613
24860
25924
26685
27563
28676
29648
30586
31736
32576
33851
34608
35798
36763
37887
38743
39569
40585
41859
42644
43521
44930
45645
46711
47596
48943
49806
50741
...

result:

ok answer: 1505, maximum: 1505

Test #33:

score: 0
Accepted
time: 510ms
memory: 94596kb

input:

2000000 2000000 2000000
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
...

output:

1804
798
1930
3174
4535
5987
7188
8190
9169
10745
11782
13175
14036
15029
16410
17426
18826
20250
21211
22492
23408
25065
26341
27464
28662
29871
30627
32175
33529
34247
35952
37045
38028
39254
40222
41442
43186
43805
45235
46567
47966
49053
50297
51087
52594
53642
54786
56378
57325
58437
59627
6106...

result:

ok answer: 1804, maximum: 1804

Test #34:

score: 0
Accepted
time: 663ms
memory: 94476kb

input:

2000000 2000000 2000000
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
...

output:

1356
750
1744
2690
3231
4464
5192
6190
7171
7664
8979
9472
10640
11256
12425
13351
14098
15167
16193
16673
17710
18817
19680
20287
21297
22100
23383
24282
25013
25751
26703
27735
28535
29378
30180
31279
32058
33169
34068
34877
35827
36693
37752
38562
39316
40375
40985
42021
42925
43876
44810
45746
4...

result:

ok answer: 1356, maximum: 1356

Test #35:

score: 0
Accepted
time: 675ms
memory: 94460kb

input:

2000000 2000000 2000000
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
...

output:

1051
515
1277
1850
2792
3414
3994
4672
5452
6150
6691
7384
8176
9071
9593
10310
10975
11581
12569
13202
13978
14676
15298
15992
16681
17295
18061
18614
19408
20291
20730
21656
22336
23098
23546
24248
25018
25749
26365
27057
27787
28663
29348
29817
30781
31245
32011
32742
33506
34068
34701
35560
3605...

result:

ok answer: 1051, maximum: 1051

Test #36:

score: 0
Accepted
time: 619ms
memory: 108036kb

input:

2000000 2000000 2000000
1410388 834484
1410388 239410
1410388 1232286
1410388 207365
1410388 1395003
1410388 1968948
1410388 576378
1410388 76728
1410388 1644827
1410388 1278820
1410388 593448
1410388 904665
1410388 1931363
1410388 1889040
1410388 1147950
1410388 218013
1410388 1688590
1410388 13887...

output:

1651
1780394
1499549
797161
1289927
539859
899300
1447201
1093225
932699
751945
722195
1288253
1321612
595076
701764
834847
1424403
774282
529058
1407883
1146132
1322755
1042481
1408325
814792
623680
514480
1423937
1484268
1394095
820509
228737
562050
504460
262514
385728
1394504
591735
482525
13176...

result:

ok answer: 1651, maximum: 1651

Test #37:

score: 0
Accepted
time: 1348ms
memory: 105484kb

input:

2000000 2000000 2000000
1686157 1036655
905644 1257773
231391 1553076
1776476 17761
1718008 397514
1502594 1699978
1112572 590070
1128891 1730637
1547654 1908592
1182198 717510
645722 749840
1307572 1364844
1466826 1763992
373885 1613469
12498 321213
265420 1503625
574762 197883
654547 1390192
19624...

output:

1365
1379901
1734560
42728
594514
1592622
944093
2818
978611
1847435
745390
1731564
1715704
1826285
1205601
1411501
1387252
166868
415127
469065
1086880
159368
1360055
1030718
555983
187353
54974
17030
977508
490771
696506
1966509
562030
1136540
1196836
1123412
626118
1269750
1470916
1038787
1457193...

result:

ok answer: 1365, maximum: 1365

Test #38:

score: 0
Accepted
time: 685ms
memory: 94652kb

input:

2000000 2000000 2000000
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
...

output:

1515
835
1529
2647
3596
4536
5752
6537
7930
8642
9659
10702
11849
12839
13746
14551
15910
16889
17626
18753
19703
20848
21946
22828
23652
24800
25854
26838
27773
28765
29989
30998
31632
32590
33565
34969
35665
36897
37532
38735
39898
40816
41633
42547
43683
44748
45534
46578
47742
48870
49806
50819
...

result:

ok answer: 1515, maximum: 1515

Test #39:

score: 0
Accepted
time: 1846ms
memory: 95140kb

input:

2000000 2000000 2000000
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
...

output:

2539
283
1461
2418
3222
3933
4757
5642
6448
7032
8055
8596
9316
10474
10942
12087
12893
13701
14500
15235
16115
16924
17597
18428
19326
20147
20775
21762
22561
23346
24175
24850
25715
26439
27384
28201
29010
29821
30621
31434
32234
33033
33833
34652
35458
36142
36992
37815
38644
39491
40153
41088
41...

result:

ok answer: 2539, maximum: 2565

Test #40:

score: 0
Accepted
time: 1144ms
memory: 90200kb

input:

2000000 2000000 2000000
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
...

output:

2964
377
1999
3000
4000
4534
5999
6584
7593
8567
9992
10999
11593
12994
13998
14991
15724
16994
17998
18994
19989
20876
21809
22613
23571
24996
25770
26837
27582
28999
29957
30851
31985
32779
33974
34999
35994
36755
37985
38986
39739
40996
41991
42986
43988
45000
45973
46973
47786
48997
49854
50990
...

result:

ok answer: 2964, maximum: 2998

Test #41:

score: 0
Accepted
time: 3322ms
memory: 111844kb

input:

2000000 2000000 2000000
194151 1938743
219729 1342843
68564 86794
693354 1338943
702775 386871
836157 501653
625353 1528914
1202559 373185
1190037 460020
109144 7201
1509959 1182372
1303399 1859980
281937 429619
1375375 1140805
1967865 1423773
274895 820740
86914 1312016
745802 1304378
1383905 79192...

output:

2946
1648197
260573
242668
1199798
1077066
1834483
1987687
1747815
14893
1881470
1521226
1357944
35892
390533
641070
1282002
851904
1425766
212830
775374
1896064
1551803
1886667
400823
1801263
1630307
575492
640224
526891
610227
576563
931703
462877
1588626
398305
1374329
125042
1943715
425097
13669...

result:

ok answer: 2946, maximum: 2998

Test #42:

score: 0
Accepted
time: 1396ms
memory: 94648kb

input:

2000000 2000000 2000000
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
...

output:

2679
106
1737
2255
3602
4501
5347
6304
6893
7951
9010
9908
10805
11709
12417
13243
14414
15241
15843
17106
18018
18907
19821
20368
21264
22524
23420
24295
25222
26103
27025
27912
28829
29726
30529
31515
32293
33316
34164
35134
36023
36894
37725
38504
39641
40531
41433
42332
43248
43911
44873
45947
4...

result:

ok answer: 2679, maximum: 2710

Test #43:

score: 0
Accepted
time: 3097ms
memory: 112004kb

input:

2000000 2000000 2000000
808248 552259
667514 1319054
1871613 39928
967451 1289759
121536 839484
1144906 293777
953710 1302471
926057 1130229
1971166 1472560
570716 319665
993182 847647
503839 1448077
1477180 1090769
866885 830795
825148 986508
1855201 601420
425225 1209935
1327152 158029
1750913 134...

output:

2729
855690
1673773
68970
1977815
1087637
1313965
803912
942888
444111
1814602
193092
1450871
1552602
1012798
1853413
826139
1783243
1457156
361946
1556640
167806
1862181
896963
306245
670198
693853
562032
1016316
1159188
43393
1574667
1420555
567346
55907
508931
784763
699879
167887
876968
925552
1...

result:

ok answer: 2729, maximum: 2800

Test #44:

score: 0
Accepted
time: 3037ms
memory: 111392kb

input:

2000000 2000000 2000000
718302 630746
525264 939615
1513350 1873077
423465 103470
951359 287841
279717 1446774
333123 1231534
1505351 1924842
373931 77349
1219573 981167
406220 1773980
900787 835783
1382738 581012
1073706 1285129
945967 1563314
1701380 1449817
1653881 342722
1239856 1648628
1205777 ...

output:

2681
567109
408844
1582512
1514653
462988
1494024
1350958
265131
1203636
1989740
559268
291192
1639928
780424
342407
1361561
1932527
284310
1523125
935750
999523
1617888
416237
1309438
1480744
1138823
897414
1033421
1941453
252958
1987663
1235093
1806193
1898916
608301
71035
1925006
948710
1745922
1...

result:

ok answer: 2681, maximum: 2750

Test #45:

score: 0
Accepted
time: 3133ms
memory: 111320kb

input:

2000000 2000000 2000000
1047008 1232125
151532 351751
52892 1005841
286679 1721611
1079778 897632
1546359 822542
1525784 480194
543504 476429
289791 1740845
1120554 931051
1115547 42416
776964 774892
332228 1748138
871235 93456
992460 173688
996367 275112
1753268 895023
1559974 1826000
527625 155211...

output:

2468
1004783
1638358
1833475
1817374
1149829
295604
1770983
599013
822782
835479
1207872
1536092
1822973
331282
697365
213443
1387487
150889
1137031
1607027
685405
1213722
1463469
422090
1578094
1167986
1063034
489926
944913
69278
924860
1829230
471979
382458
1206596
1258612
100620
812129
604008
847...

result:

ok answer: 2468, maximum: 2530

Test #46:

score: 0
Accepted
time: 1778ms
memory: 94612kb

input:

2000000 2000000 2000000
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
...

output:

2376
493
1602
1964
2955
3743
4754
5606
6003
6958
7728
8613
9344
10408
11041
12003
12807
13357
14292
15209
16001
16805
17615
18263
19210
20024
20804
21472
22413
23136
23921
24822
25505
26427
27232
28025
28829
29619
30436
31238
31971
32817
33611
34430
35239
36034
36844
37570
38437
39246
40033
40831
41...

result:

ok answer: 2376, maximum: 2401

Test #47:

score: 0
Accepted
time: 2618ms
memory: 95068kb

input:

2000000 2000000 2000000
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
...

output:

1941
608
710
1861
2350
2805
3432
4315
4968
5413
6209
6484
7401
7999
8693
9303
9930
10552
11176
11616
12406
12947
13644
14160
14732
15505
16143
16766
17377
17742
18628
19235
19666
20492
21100
21711
22341
22969
23579
24219
24840
25454
26082
26696
27194
27927
28550
29184
29791
30423
31046
31671
32273
3...

result:

ok answer: 1941, maximum: 1960

Test #48:

score: 0
Accepted
time: 592ms
memory: 109448kb

input:

2000000 2000000 1978001
1 490000
490001 1
2 489999
490001 2
3 489998
490001 3
4 489997
490001 4
5 489996
490001 5
6 489995
490001 6
7 489994
490001 7
8 489993
490001 8
9 489992
490001 9
10 489991
490001 10
11 489990
490001 11
12 489989
490001 12
13 489988
490001 13
14 489987
490001 14
15 489986
4900...

output:

989001
1
3
5
7
9
11
13
15
17
19
21
23
25
27
29
31
33
35
37
39
41
43
45
47
49
51
53
55
57
59
61
63
65
67
69
71
73
75
77
79
81
83
85
87
89
91
93
95
97
99
101
103
105
107
109
111
113
115
117
119
121
123
125
127
129
131
133
135
137
139
141
143
145
147
149
151
153
155
157
159
161
163
165
167
169
171
173
...

result:

ok answer: 989001, maximum: 989001

Test #49:

score: 0
Accepted
time: 849ms
memory: 107792kb

input:

2000000 2000000 1996001
14736 484265
953815 543188
350019 148982
499001 304526
897544 499001
181207 317794
499001 444963
623433 499001
854189 642814
871771 499001
499001 476093
561337 499001
499001 306252
192341 306660
340717 158284
207606 291395
307398 191603
438969 60032
977627 499001
694717 80228...

output:

998001
967049
415065
408859
462539
975307
1817833
413211
1109695
845310
451567
1714807
1233409
1019775
837006
1400830
1547431
1891954
409382
13008
902070
1085913
862264
443914
1350677
865775
90086
1848670
1303492
1808210
523112
740796
1602718
683965
1813783
1094271
1656325
1788799
988449
1754202
147...

result:

ok answer: 998001, maximum: 998001

Test #50:

score: 0
Accepted
time: 1397ms
memory: 120608kb

input:

2000000 2000000 1999999
268787 212137
905395 946062
578271 1714792
1614896 1709280
854272 878881
905395 1293382
905395 1175387
905395 459499
1747988 83010
1388833 1857081
955129 615008
146195 1709280
905395 795775
513349 906379
847560 1709280
1298422 1709280
573001 1836920
905395 1629231
1272015 197...

output:

1000000
115766
577777
257360
1704885
863410
1326794
1033559
1743080
1305777
1008973
1096392
754493
1650047
1192368
488459
1024031
1032395
1210670
1236728
374149
1318578
64199
1347537
1281297
631831
1122962
1519045
1707189
42748
1025177
1764784
791362
1397914
1632739
1596858
1254316
435693
564099
166...

result:

ok answer: 1000000, maximum: 1000000

Test #51:

score: 0
Accepted
time: 2097ms
memory: 97824kb

input:

2000000 2000000 1999992
1 333333
333334 1
1 67693
2 333332
333334 2
2 241546
3 333331
333334 3
3 293203
4 333330
333334 4
4 79783
5 333329
333334 5
5 282986
6 333328
333334 6
6 106346
7 333327
333334 7
7 256497
8 333326
333334 8
8 119905
9 333325
333334 9
9 254844
10 333324
333334 10
10 209942
11 33...

output:

665441
1
4
7
10
13
16
19
22
25
28
31
34
37
40
43
46
49
52
57
58
61
64
67
70
73
76
79
82
85
88
91
94
97
100
103
106
109
112
115
118
121
124
127
132
133
136
139
142
145
148
151
154
159
160
163
166
169
172
175
178
181
184
189
190
193
196
201
202
205
208
211
214
217
220
223
226
229
232
235
238
241
244
2...

result:

ok answer: 665441, maximum: 666667

Test #52:

score: 0
Accepted
time: 2760ms
memory: 99204kb

input:

2000000 2000000 1999995
434184 430351
85401 119908
233334 45603
286245 613757
488439 233334
238416 661586
320615 579387
135012 98322
655583 406691
54300 100591
511235 233334
349357 233334
582778 233334
585943 394823
437833 542529
117171 116163
657733 233334
233334 210358
226095 7239
416103 525868
10...

output:

665438
280424
1694943
1936027
1633861
57880
1372289
1865813
1550119
528460
1649747
1792031
43581
910874
926622
937105
188176
1204071
219099
1689949
578116
1979175
1440079
573923
1976763
386611
150522
49291
1925251
845908
1913593
1550873
502945
1257439
843424
1764207
1003134
54814
1777426
751974
9204...

result:

ok answer: 665438, maximum: 666667

Test #53:

score: 0
Accepted
time: 2997ms
memory: 119396kb

input:

2000000 2000000 1999997
99936 878006
132599 1532680
808157 573164
99936 1419983
99936 1537850
1848392 1157400
137701 902241
1274770 1105380
99936 102556
792921 1472686
1884966 198885
1687958 1098615
73371 1581777
253000 548850
74925 1185404
1693642 1927029
1534302 837664
796187 910953
99936 236818
1...

output:

664557
1254211
1543449
186
1245452
724255
1208814
1625887
943963
706253
283220
1554456
1519208
495961
288560
1496467
1433057
1175298
1489653
1746600
1358063
1428697
475160
1737299
772667
1094515
622278
1094488
1942173
349206
13749
256303
903048
1601504
1030201
40817
1916077
276563
693543
561399
1077...

result:

ok answer: 664557, maximum: 666667

Test #54:

score: 0
Accepted
time: 3162ms
memory: 120136kb

input:

2000000 2000000 1999999
889649 520969
523056 1286405
1496086 520969
1306343 520969
905937 1014591
1966446 541194
994929 1903865
729217 52620
79941 863746
1966446 568167
1715964 172015
1966446 380997
566912 1559754
268280 188433
568588 63281
1966446 1432646
1926617 637303
1966446 992205
1992855 42917...

output:

863797
548428
1120998
1119226
1133444
1914288
695261
1766787
1551420
1558559
1726741
417356
957959
1790802
728197
648812
1470958
189247
796399
1865115
1096297
1270901
1501433
1700802
310196
1319135
1310066
495133
1865446
943688
1664729
1753866
1971954
1928705
1905802
1966030
45950
575538
176732
1684...

result:

ok answer: 863797, maximum: 866667

Test #55:

score: 0
Accepted
time: 498ms
memory: 132204kb

input:

2000000 2000000 1999996
1000001 1000002
1000000 1000001
999999 999998
1000000 999999
1000003 1000004
1000002 1000003
999997 999996
999998 999997
1000005 1000006
1000004 1000005
999995 999994
999996 999995
1000007 1000008
1000006 1000007
999993 999992
999994 999993
1000009 1000010
1000008 1000009
999...

output:

1999995
1999995
1999996
1999991
1999992
1999987
1999988
1999983
1999984
1999979
1999980
1999975
1999976
1999971
1999972
1999967
1999968
1999963
1999964
1999959
1999960
1999955
1999956
1999951
1999952
1999947
1999948
1999943
1999944
1999939
1999940
1999935
1999936
1999931
1999932
1999927
1999928
1999...

result:

ok answer: 1999995, maximum: 1999995

Test #56:

score: 0
Accepted
time: 2281ms
memory: 67560kb

input:

200000 200000 2000000
664 160724
29731 148042
89719 133217
96668 12241
74180 45431
80359 80359
81360 183670
70023 129871
29348 129404
80903 76108
83946 20731
20513 854
62313 199982
75818 72015
848 120468
52461 121850
28584 2960
29997 157192
5871 138992
50476 50476
63681 7511
74265 141991
37110 18983...

output:

200000
1422304
910087
760404
803441
1913598
662061
1153414
1946110
337487
1776265
839969
1624090
1053228
1405443
1480851
281328
317527
12356
1530178
1576872
828618
1337590
1543349
621249
538649
487489
1915678
719043
1115996
1967990
1798990
669080
860856
348105
1807933
578467
686119
1974500
865281
98...

result:

ok answer: 200000, maximum: 200000

Test #57:

score: 0
Accepted
time: 2523ms
memory: 68788kb

input:

200000 200000 2000000
78113 189591
135248 140966
13931 85453
7945 90406
120041 142669
124018 134787
147034 85469
98588 11461
112366 20587
51999 86074
175326 18428
185557 52954
15782 89330
28609 49472
191098 61077
114813 186608
107339 61746
157614 161856
13633 92037
144083 66351
102406 185761
107676 ...

output:

200000
1979673
558421
1535812
1482463
937976
682242
704090
1132901
952434
1404786
1474850
538867
411666
1542150
1660800
246920
1450502
472627
790480
955969
177733
1741002
1304305
1073514
986808
1311520
178354
1411301
300756
634693
1072495
660879
242723
220100
272738
1487779
1134967
1571835
925146
44...

result:

ok answer: 200000, maximum: 200000

Test #58:

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

input:

19 19 56
5 19
9 19
2 15
9 17
15 2
4 11
2 6
18 19
16 19
10 4
9 8
12 8
9 13
3 9
14 10
8 5
3 6
6 19
7 12
6 12
18 11
16 15
5 13
3 18
11 17
7 6
8 1
16 2
18 6
9 3
7 18
5 6
1 14
7 11
2 9
2 11
9 15
10 5
14 7
2 19
3 8
1 6
3 11
12 7
5 8
6 15
2 1
10 11
4 6
9 12
5 14
17 15
1 10
9 4
19 10
8 13

output:

18
33
47
14
6
23
20
31
16
30
10
25
12
39
5
9
52
29
55

result:

ok answer: 18, maximum: 18

Test #59:

score: 0
Accepted
time: 5ms
memory: 11932kb

input:

18 15 57
1 11
5 11
17 2
7 8
4 2
3 13
4 5
2 11
3 6
7 12
1 8
5 15
5 10
16 1
13 9
15 7
4 15
11 10
15 15
2 8
5 7
1 3
8 15
6 15
13 4
9 9
4 3
12 9
16 2
17 6
4 12
8 4
16 10
7 9
14 1
4 11
10 12
3 14
16 5
5 12
13 15
5 4
1 4
13 8
18 9
11 15
15 13
5 6
1 1
4 8
3 9
7 5
10 10
12 4
5 8
3 4
3 8

output:

15
22
8
38
7
21
24
34
32
37
18
44
35
47
29
30

result:

ok answer: 15, maximum: 15

Test #60:

score: 0
Accepted
time: 779ms
memory: 86152kb

input:

678566 678566 1999984
2 9
21 28
40 47
59 66
78 85
97 104
116 123
135 142
154 161
173 180
192 199
211 218
230 237
249 256
268 275
287 294
306 313
325 332
344 351
363 370
382 389
401 408
420 427
439 446
458 465
477 484
496 503
515 522
534 541
553 560
572 579
591 598
610 617
629 636
648 655
667 674
686...

output:

642852
1428561
821423
1642845
464283
1357133
857137
1857129
1285705
1464275
178571
1142849
1928557
71429
35715
1499989
1821415
892851
714281
1428562
821424
1642846
464284
1357134
857138
1857130
1285706
1464276
178572
1142850
1928558
71430
35716
1499990
1821416
892852
714282
1428563
1535705
1642847
4...

result:

ok answer: 642852, maximum: 642852

Test #61:

score: 0
Accepted
time: 3065ms
memory: 67844kb

input:

200000 200000 2000000
69876 139185
62524 62525
138 133262
71806 186817
33732 168283
95489 99486
106518 179682
172716 107457
19216 58015
99845 73717
42148 139724
168868 168869
97919 20416
87128 1949
30243 30244
75600 151450
35580 76098
104714 133433
89087 155081
129591 132925
62284 58630
156482 15249...

output:

199992
1083857
781387
1201251
203002
1650129
58270
495182
815126
455936
456296
6164
1815629
1692099
136656
1038339
674524
1057801
617027
921038
1031544
277880
337534
469496
1605627
1859033
1756514
1499363
1655663
462707
1065005
1719427
1939996
168386
1529796
1102046
130500
414616
1851792
1271447
924...

result:

ok answer: 199992, maximum: 199999

Test #62:

score: 0
Accepted
time: 1587ms
memory: 67692kb

input:

150000 150000 2000000
54330 43360
16319 88652
141294 26736
20468 113762
97646 145993
60941 104416
129709 105019
66588 68832
142233 2395
108417 104322
6989 77878
88615 37170
143108 87699
61046 70285
57071 89523
51727 37170
9324 127
92556 41325
130418 139947
64056 139176
132912 7652
97699 100501
27494...

output:

150000
463264
862069
399724
421618
831556
1204692
59152
679564
724518
1423219
82209
1543965
752316
1749548
506722
415344
357272
883361
1294653
854811
1524656
780287
559436
302240
1061444
1484224
1801162
1575297
669477
58107
359948
1402391
585488
777218
1942419
143672
111779
1479025
1580330
42855
817...

result:

ok answer: 150000, maximum: 150000

Test #63:

score: 0
Accepted
time: 1419ms
memory: 64304kb

input:

100000 100000 2000000
49929 65074
29149 97704
24293 81423
66419 49097
11433 84252
92840 60952
62698 90526
88909 86548
17320 20088
51288 89806
96298 83831
38740 34975
44261 80408
29420 71018
58482 68503
52534 60006
58264 78391
56087 93185
82812 85036
8031 14160
66351 20760
14687 96078
15299 90962
518...

output:

100000
512483
768147
1725350
838626
1848709
1158337
1785079
1584537
384606
1590325
963163
1468277
1608052
1684486
1500059
1428949
996351
156736
332934
196614
212628
1230698
683172
1512656
970826
1490895
1051803
505744
91601
112511
213904
1427017
1467698
354379
523173
15655
1833070
406625
185274
7595...

result:

ok answer: 100000, maximum: 100000

Test #64:

score: 0
Accepted
time: 1628ms
memory: 67184kb

input:

170000 170000 2000000
3612 9795
147435 143171
69805 6608
61910 137634
126397 3230
26553 86436
131227 26454
121363 88860
38380 153427
137943 57048
131806 10483
94826 52628
161151 15843
9778 152697
134661 39645
90985 3918
133310 61463
53083 17459
166446 43454
5274 47145
12452 26837
38319 22897
21654 3...

output:

170000
1890400
457988
938111
871948
1539206
652393
1094406
1753062
1781845
727208
420430
1390177
471268
324046
1616737
480697
367949
1296410
1756539
49832
762711
376012
1676364
1206134
945093
39263
1276665
370952
1359185
630500
420509
945524
1426315
1775365
506340
1277885
773296
1608881
1790243
1678...

result:

ok answer: 170000, maximum: 170000

Test #65:

score: 0
Accepted
time: 3000ms
memory: 71792kb

input:

300000 300000 2000000
105039 159953
139571 260965
123457 12072
17324 259747
138608 110296
66462 272340
110874 210438
122930 567
110889 187260
121538 250086
46088 46088
241860 241860
26309 180815
214266 214266
12616 253964
96698 176066
141876 141876
16967 250287
85301 158549
2708 241153
8648 225106
3...

output:

299754
46878
1017769
1826751
1806040
253830
1603618
1298447
1337854
610682
1834993
886484
1892887
1280909
280271
1641353
1164389
1502611
1758568
162386
476319
1812674
1347987
343810
1377918
1656117
543602
1927650
413397
1637328
512475
114900
1898229
776250
1236931
428569
1728013
1108389
415258
26955...

result:

ok answer: 299754, maximum: 300000

Test #66:

score: 0
Accepted
time: 3237ms
memory: 69332kb

input:

250000 250000 2000000
27634 140210
64795 131118
90767 223433
53039 125810
13117 174409
50704 184798
97142 128269
124910 141738
7859 187326
148 117705
43722 145917
79011 152539
67052 44360
55495 46271
37540 172469
106827 175922
124820 124820
119888 78477
89586 71525
98812 210351
12073 12073
58746 118...

output:

249973
616736
81757
1547462
190674
828031
25359
672106
155382
1394341
1531056
176151
1987869
1550914
286169
761539
895283
843917
747789
1589686
570829
1903780
81174
959993
1871870
1082602
132185
726434
439173
1833004
61471
1413505
542869
1254094
1392630
763929
543835
387410
1602451
1653027
1006676
1...

result:

ok answer: 249973, maximum: 250000

Test #67:

score: 0
Accepted
time: 1803ms
memory: 66672kb

input:

150000 150000 2000000
72620 63166
60504 112442
108921 108921
29772 43296
68163 7790
21709 4273
56314 136135
20691 50652
16581 140984
58236 73716
51216 16671
69149 37016
65297 33957
103215 103215
74270 104198
44645 108573
23166 89329
25025 61044
19899 13984
42237 116930
27561 42622
9294 124923
28200 ...

output:

150000
1984902
1115001
1898988
417330
1547551
276538
1358345
1819900
937879
1444883
1061931
1597016
756817
20164
677113
1629611
99711
752549
193740
1436461
720853
1463520
1161270
629207
1645046
74207
1401928
511267
75585
1907184
625540
958037
120308
97318
1607140
301899
1892924
87220
883536
914050
1...

result:

ok answer: 150000, maximum: 150000

Test #68:

score: 0
Accepted
time: 3012ms
memory: 70748kb

input:

300000 300000 2000000
62650 298300
32903 221473
148069 44049
44572 26768
236134 221925
218630 246970
299097 142733
128764 279567
255792 280789
200357 124110
161834 172221
160384 136502
195281 234298
84582 27950
226733 5498
136989 132152
54414 16936
265690 73937
261962 2088
177657 40267
140454 41167
...

output:

299747
1455724
398917
227918
1021721
1228006
1150666
1566307
841703
381882
521262
1334055
177396
1338675
1376692
1455842
1613277
805916
80541
914933
1001307
419217
1560309
1642260
808398
391755
749264
857561
69596
730531
165528
1688454
386457
315164
46858
1857451
272923
1517993
1834059
624135
9047
1...

result:

ok answer: 299747, maximum: 300000

Test #69:

score: 0
Accepted
time: 3216ms
memory: 71584kb

input:

250000 250000 2000000
42479 78880
229459 199048
215225 39015
67503 87209
44206 177384
181335 32120
218106 232029
131164 22796
37859 147919
118814 39019
18616 29193
56610 107857
234124 125147
192155 239675
61943 77090
27213 222986
91948 178876
16128 160637
201088 72175
125889 246664
203146 93005
4409...

output:

249976
1129448
451678
1890003
631304
397076
440720
1522892
1714173
71120
925209
862386
1440435
501036
546204
1487463
1073886
1823411
1619191
777902
1142126
325053
1796318
348084
102226
253381
192897
708588
1563706
1664878
1104225
1088321
917818
685634
1532388
1036592
916914
1693516
586322
433628
170...

result:

ok answer: 249976, maximum: 250000

Test #70:

score: 0
Accepted
time: 1366ms
memory: 67376kb

input:

150000 150000 2000000
50295 49713
56629 139465
36117 134593
5619 102228
80472 1462
95204 127674
1068 7827
51488 105256
95178 49920
119485 149320
23548 42551
50754 103530
75573 125223
100703 122055
124159 49080
76472 40393
68125 129299
42342 136831
132673 144177
84740 44446
93983 5263
135511 101001
8...

output:

150000
27257
429908
1471375
1212523
1042361
592155
1042614
513593
1381396
102372
1808839
435869
214811
1260929
1230024
1435594
1689876
1759667
1361871
317799
220935
1975380
1948814
1234141
1241464
19674
968222
758531
1637355
884640
1725607
1913532
1933377
888793
1275287
1110831
644321
606005
564758
...

result:

ok answer: 150000, maximum: 150000

Test #71:

score: 0
Accepted
time: 3084ms
memory: 74468kb

input:

400000 400000 2000000
321215 315599
86143 221204
352388 187875
257057 180810
328703 309356
16156 79952
233287 383469
186330 235642
319570 61164
346523 161292
55301 225868
2879 20470
104317 87601
180410 121340
133967 159959
348782 315741
122573 274655
120564 187129
173692 27065
88012 223481
387616 11...

output:

399770
1158189
71628
1904563
1828436
1593003
1669547
610012
33922
1752082
874857
795991
774602
558677
555233
671574
915043
277744
1534477
1841162
1550715
1903034
563964
1095545
1638216
932864
1752756
759533
871935
1774635
1610162
1024170
400024
116157
1694376
678674
1362412
1688826
1001831
105704
80...

result:

ok answer: 399770, maximum: 399999

Test #72:

score: 0
Accepted
time: 2970ms
memory: 77884kb

input:

500000 500000 2000000
41258 153561
273035 392661
397020 224200
58608 488748
297485 331670
346512 161259
260630 322105
27539 336545
463787 370096
99457 441303
498391 439092
87501 228594
290136 149064
113483 4060
362030 219228
390362 358525
31241 457801
137393 40805
17584 133295
196052 301094
401557 1...

output:

499208
1974737
362799
1068004
1461455
1202946
1043076
1780959
554373
1537904
1228214
792713
1014061
696865
1692627
1703201
1632637
1365159
1076207
1568063
595087
1486940
484419
864205
157160
221664
1635483
1960066
1140344
548611
1765603
1511302
1469401
16561
1762444
1596929
1091755
1341196
1475806
4...

result:

ok answer: 499208, maximum: 499999

Test #73:

score: 0
Accepted
time: 3062ms
memory: 76260kb

input:

400000 400000 2000000
24411 11654
148356 10647
227740 5879
386 391268
257182 171
305545 121948
254087 275542
25015 358236
249767 9645
195114 87802
169705 376325
124126 126282
107814 30391
80630 94487
363646 11171
333939 69350
32996 239172
12446 102037
12154 287491
48965 380418
271749 80432
35829 284...

output:

399820
797552
930525
328109
673317
1347166
1274223
850555
760390
883355
1415184
1242147
1959498
1950667
1648379
1673097
1670816
359484
645609
1745953
427156
287818
1426941
263187
1502168
1339405
1753573
1913738
1894179
1509588
1489969
1699562
728744
1003106
138825
312538
394534
1438691
197638
120011...

result:

ok answer: 399820, maximum: 399999

Test #74:

score: 0
Accepted
time: 2964ms
memory: 79748kb

input:

500000 500000 2000000
330811 376879
172454 450741
114896 107867
402163 434806
182433 482459
398350 174732
496493 365171
259063 10910
25942 383521
217410 99230
51323 242993
272491 473326
102357 14366
462674 22816
104426 465142
197666 392939
437531 373348
232972 88117
93026 466729
208134 414081
495308...

output:

497443
935475
1397269
477773
244208
1867684
243142
177790
468997
1899956
1621739
363915
1891255
1437012
1695706
857613
885772
1424000
577543
661871
1945033
658997
629413
1643636
1292571
1000030
1750846
1046564
1522368
922933
64644
162260
852818
1452586
559981
1633830
1348231
912285
205132
1285872
84...

result:

ok answer: 497443, maximum: 499999

Test #75:

score: 0
Accepted
time: 3059ms
memory: 80304kb

input:

500000 500000 2000000
322807 410913
452232 241894
481008 454652
260794 213674
459518 290982
479472 264462
27434 165765
358893 217733
423071 496151
100484 202619
235325 285732
72905 296158
15183 71591
100768 166531
427812 493809
159311 497845
7747 178375
95452 135039
450314 363747
17199 456516
119084...

output:

498055
1093804
226539
1940943
825643
602649
401158
1607407
66197
1194833
145260
18693
173478
534835
1686914
898180
739936
981368
769200
1699393
631886
844207
1513562
1524894
953779
587098
1691369
1428400
1831486
457185
895013
1671795
1548835
902219
44114
661446
202047
900854
1389610
1511865
1248162
...

result:

ok answer: 498055, maximum: 499999

Test #76:

score: 0
Accepted
time: 2896ms
memory: 65284kb

input:

100000 100000 2000000
86851 32197
68370 43547
68302 96976
78092 86171
70780 80060
33051 59116
41988 28246
70392 28796
94241 66628
35002 42626
76776 43819
18820 23892
34568 2129
31551 47980
82210 28398
40386 93071
76591 10891
32718 90249
31724 52852
46617 3559
2880 50447
66185 56127
12402 10349
77779...

output:

99999
465045
1343066
969079
1421778
442230
1880126
774882
630111
1636492
671541
724208
131812
949978
1366613
1808204
1514523
847252
56652
1968804
251449
949413
1024767
955524
420301
867201
932429
1984470
237676
1993991
1917528
1040464
1837640
796365
1878034
1650779
1097241
323961
539074
1589041
1107...

result:

ok answer: 99999, maximum: 99999