QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#35562#1454. Um nik's Algorithmqingyu_orzTL 3920ms312852kbC++3.1kb2022-06-16 20:47:252022-06-16 20:47:26

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-06-16 20:47:26]
  • 评测
  • 测评结果:TL
  • 用时:3920ms
  • 内存:312852kb
  • [2022-06-16 20:47:25]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
namespace file_read{
    namespace input_file_io{
        char ib[1<<25],*ip1=ib,*ip2=ib;
        inline char gc(){
#ifdef JohnAlfnov
			return getchar();
#else
            return (ip1==ip2&&(ip2=(ip1=ib)+fread(ib,1,1<<24,stdin)),ip1==ip2?EOF:*ip1++);
#endif
        }
        inline int read(){
            int x=0;
            char c=gc();
            while(c<'0'||c>'9')c=gc();
            while(c>='0'&&c<='9'){
                x=(x<<3)+(x<<1)+(c^'0');
                c=gc();
            }
            return x;
        }
    };
    namespace output_file_io{
        char ob[1<<23],*op=ob;
        inline void pc(char c){
            *op++=c;
        }
        void write(int x){
            if(x<0){
                pc('-');
                x=-x;
            }
            if(x==0)pc('0');
            static int number_stack[40];
            int total_count=0;
            while(x)number_stack[++total_count]=x%10,x/=10;
            while(total_count){
                pc(number_stack[total_count]+'0');
                --total_count;
            }
        }
        inline void final_write(){
            fwrite(ob,op-ob,1,stdout);
    	}
    };
	using namespace input_file_io;
	using namespace output_file_io;
};
using namespace file_read;
int n,S,T;
int hd[5000005],mw[5000005],l[5000005],pre[5000005];
int nxt[12000005],c[12000005],bb[12000005],tt[12000005],tot=1;
inline void addedge(int u,int v,int w,int bh){
	if(!hd[u])hd[u]=++tot;
	else nxt[mw[u]]=++tot;
	mw[u]=tot;
	c[tot]=w,bb[tot]=bh,tt[tot]=v;
}
int q[5000005];
bool bfs(){
	for(int i=1;i<=n;++i)l[i]=1e9+7,pre[i]=hd[i];
	l[S]=1;
	int h=0,t=-1;
	q[++t]=S;
	while(h<=t){
		int x=q[h++];
		for(int i=hd[x];i;i=nxt[i]){
			int v=tt[i];
			if(c[i]==0)continue;
			if(l[v]>l[x]+1){
				l[v]=l[x]+1;
				if(v==T)return 1;
				q[++t]=v;
			}
		}
	}
	return 0;
}
int ans=0;
int dinic(int x,int rl){
	if(x==T)return rl;
	int he=0;
	for(int i=pre[x];i;i=nxt[i]){
		pre[x]=i;
		if(c[i]==0)continue;
		int v=tt[i];
		if(l[v]!=l[x]+1)continue;
		int ll=dinic(v,min(c[i],rl));
		rl-=ll,he+=ll;
		c[i]-=ll,c[i^1]+=ll;
		if(!rl)return he;
	}
	return he;
}
int u[2000005],v[2000005];
bool vist[2000005];
int main(){
	int aa=clock();
	int n1=read(),n2=read(),m=read();
	n=1+n1+n2+1;
	S=1,T=n;
	for(int i=1;i<=n1;++i)addedge(S,1+i,1,0),addedge(1+i,S,0,0);
	for(int i=1;i<=n2;++i)addedge(1+n1+i,T,1,0),addedge(T,1+n1+i,0,0);
	for(int t=1;t<=m;++t)u[t]=read(),v[t]=read();
	for(int t=1;t<=m;t+=2){
		addedge(1+u[t],1+n1+v[t],1,t);
		addedge(1+n1+v[t],1+u[t],0,0);
	}
	for(int t=2;t<=m;t+=2){
		addedge(1+u[t],1+n1+v[t],1,t);
		addedge(1+n1+v[t],1+u[t],0,0);
	}
	for(int i=1;i<=19;++i){
		if(!bfs())break;
		if(1.0*(clock()-aa)/CLOCKS_PER_SEC>3.37)break;
		ans+=dinic(S,INT_MAX);
	}
	write(ans),pc('\n');
	for(int i=2;i<=1+n1;++i)for(int j=hd[i];j;j=nxt[j]){
		if(c[j])continue;
		int dd=tt[j];
		if(dd<2+n1||dd>1+n+n1)continue;
		vist[bb[j]]=1;
	}
	for(int i=1;i<=m;++i)if(vist[i])write(i),pc('\n');
	final_write();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 26200kb

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: 26240kb

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: 25992kb

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
2
6
11
17
21
23
27
29
31
33
39
40
47
49
53
54
55
59
61
75
81
83
85
89
93
95
97
103
105
109
119
123
125
129
133
135
137
143
147
153
159
161
163
165
169
171
173
179
181
187
191
194
195
197
199
205
206
215
217
227
233
247
249
253
255
257
259
263
265
267
269
275
279
291
297
299
311
319
325
331
339
...

result:

ok answer: 1000, maximum: 1000

Test #4:

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

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
53
191

result:

ok answer: 2, maximum: 2

Test #5:

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

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
1
2
5
6
7
10
11
12
15
18
19
21
22
23
24
25
29
31
33
38
39
42
43
44
45
46
47
49
50
52
53
54
58
59
60
61
62
65
66
67
69
73
74
75
76
77
78
80
84
87
88
90
91
92
93
94
96
97
99
100
103
105
106
111
113
114
117
121
123
124
125
126
127
128
129
130
131
133
135
137
139
143
146
147
148
149
150
151
152
155
...

result:

ok answer: 540, maximum: 540

Test #6:

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

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
1
3
5
7
9
11
13
15
16
17
18
19
20
21
23
27
29
31
33
34
35
37
39
40
41
42
43
45
46
47
48
49
51
52
53
54
60
61
63
65
66
68
70
71
73
75
77
78
79
81
83
84
85
87
89
91
94
95
96
101
103
104
105
107
109
110
113
115
117
118
123
125
127
129
130
132
133
135
137
139
141
143
145
150
151
152
153
156
157
158
...

result:

ok answer: 944, maximum: 944

Test #7:

score: 0
Accepted
time: 3723ms
memory: 310528kb

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:

1085415
1
5
7
8
9
10
12
13
18
19
23
25
27
29
31
33
34
35
36
38
39
40
42
43
44
45
46
55
56
57
58
59
61
62
63
64
65
66
67
68
69
71
72
73
74
75
77
78
79
81
83
88
89
91
92
93
96
97
99
100
103
105
107
109
111
114
116
119
120
121
123
125
127
128
129
131
132
133
134
135
136
137
138
139
140
141
143
145
146
...

result:

ok answer: 1085415, maximum: 1088264

Test #8:

score: 0
Accepted
time: 3682ms
memory: 310484kb

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:

1085136
2
3
4
5
6
8
9
11
13
14
15
17
18
19
20
23
24
25
28
30
37
38
39
40
41
42
43
44
45
46
47
48
49
51
53
54
55
56
59
60
62
64
65
67
72
74
75
76
77
80
83
84
86
89
91
93
98
100
101
105
106
107
108
109
112
113
115
117
122
123
125
127
128
130
131
133
134
135
137
138
139
140
141
142
145
146
147
149
150
...

result:

ok answer: 1085136, maximum: 1088048

Test #9:

score: 0
Accepted
time: 3747ms
memory: 310452kb

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:

1084966
3
5
7
8
11
12
14
15
17
19
22
24
25
27
29
30
31
33
34
35
39
40
41
42
44
46
47
49
50
51
53
55
56
58
59
61
62
66
67
72
73
74
76
77
78
79
80
81
83
84
85
87
89
90
91
93
95
96
97
98
99
100
101
103
105
106
107
109
111
113
114
115
116
119
120
121
122
123
124
125
126
127
128
130
131
133
134
136
137
1...

result:

ok answer: 1084966, maximum: 1087919

Test #10:

score: 0
Accepted
time: 3693ms
memory: 310312kb

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:

1085120
1
2
3
4
5
8
9
11
12
13
16
17
18
19
20
21
25
26
28
30
31
34
37
39
41
42
44
45
47
49
55
56
58
59
60
61
62
64
65
66
69
71
72
73
74
75
76
77
79
80
85
87
89
90
91
95
96
97
98
99
101
102
103
104
105
106
107
108
111
114
117
118
119
120
121
122
123
124
125
126
127
129
131
132
133
134
135
137
140
143...

result:

ok answer: 1085120, maximum: 1088039

Test #11:

score: 0
Accepted
time: 3679ms
memory: 310464kb

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:

1085248
1
2
4
5
8
9
11
13
15
17
19
20
22
23
25
26
27
29
30
31
33
37
38
40
41
42
43
45
47
48
51
52
53
54
55
56
58
59
60
61
63
64
66
67
68
69
71
72
73
78
79
81
84
85
89
91
92
93
94
95
97
98
99
103
106
107
109
110
113
114
115
120
121
122
123
124
125
126
130
131
132
135
136
137
139
141
143
145
150
151
1...

result:

ok answer: 1085248, maximum: 1088084

Test #12:

score: 0
Accepted
time: 3748ms
memory: 310428kb

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:

1084302
1
2
6
7
14
15
17
20
21
22
23
27
32
33
34
36
38
39
41
44
45
47
48
51
54
55
57
58
60
61
62
63
64
66
67
70
74
75
77
81
86
87
90
94
95
97
98
99
100
103
107
109
110
111
112
113
116
117
118
123
128
129
130
132
133
135
137
138
142
143
145
147
148
150
151
153
154
155
157
158
159
160
161
162
165
172
...

result:

ok answer: 1084302, maximum: 1087210

Test #13:

score: 0
Accepted
time: 3648ms
memory: 311784kb

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:

1535191
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
27
28
29
30
33
35
36
37
38
39
42
44
46
47
48
49
50
51
53
54
55
56
57
59
60
61
63
64
65
66
67
68
69
71
72
73
74
75
77
79
80
81
82
83
84
85
87
88
89
90
92
93
95
96
97
99
100
104
105
106
107
109
110
111
112
113
114
115
116
119
120
1...

result:

ok answer: 1535191, maximum: 1535209

Test #14:

score: 0
Accepted
time: 2993ms
memory: 312712kb

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
1
2
5
6
7
8
9
10
11
12
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
62
63
64
65
66
67
68
69
70
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
94
95
96
97
98
99
100
101
102
103
104
105...

result:

ok answer: 1802113, maximum: 1802113

Test #15:

score: 0
Accepted
time: 2804ms
memory: 312852kb

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
1
2
3
4
5
6
7
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
31
32
33
34
35
36
37
38
39
40
41
42
43
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
...

result:

ok answer: 1900296, maximum: 1900296

Test #16:

score: 0
Accepted
time: 2519ms
memory: 297868kb

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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
...

result:

ok answer: 1999999, maximum: 1999999

Test #17:

score: 0
Accepted
time: 1217ms
memory: 300748kb

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
1
5
7
11
13
23
33
35
41
45
49
51
53
63
83
127
135
147
157
117908
171417
411326
480387
519318
549914
597961
628049
801078
1093525
1104146
1247107
1572595
1587516
1609938
1706908
1802238
1826967
1958748

result:

ok answer: 38, maximum: 38

Test #18:

score: 0
Accepted
time: 983ms
memory: 301372kb

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
3
804866

result:

ok answer: 2, maximum: 2

Test #19:

score: 0
Accepted
time: 1017ms
memory: 301380kb

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

result:

ok answer: 2, maximum: 2

Test #20:

score: 0
Accepted
time: 1474ms
memory: 301448kb

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
1
3
5
7
11
13
23
27
29
31
33
37
39
41
47
49
53
55
57
65
67
73
75
77
81
83
85
87
91
93
103
115
119
125
129
131
133
135
141
143
145
147
149
155
157
159
161
167
169
171
173
175
179
181
183
189
197
209
211
213
215
223
225
227
231
233
237
239
245
247
251
255
261
273
275
279
293
299
307
319
325
327
34...

result:

ok answer: 444, maximum: 444

Test #21:

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

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
18
52
86
120
154
188
222
256
273
307
341
375
409
443
477
511
514
532
550
568
586
604
622
640
641
659
677
695
713
731
749
767

result:

ok answer: 32, maximum: 32

Test #22:

score: 0
Accepted
time: 202ms
memory: 102976kb

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
818
2452
4086
5720
7354
8988
10622
12256
13890
15524
17158
18792
20426
22060
23694
25328
26962
28596
30230
31864
33498
35132
36766
38400
40034
41668
43302
44936
46570
48204
49838
51472
53106
54740
56374
58008
59642
61276
62910
64544
66178
67812
69446
71080
72714
74348
75982
77616
79250
80884
82...

result:

ok answer: 1632, maximum: 1632

Test #23:

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

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
64
192
320
448
576
704
832
960
1088
1216
1344
1472
1600
1728
1856
1984
2112
2240
2368
2496
2624
2752
2880
3008
3136
3264
3392
3520
3648
3776
3904
4032
4097
4225
4353
4481
4609
4737
4865
4993
5121
5249
5377
5505
5633
5761
5889
6017
6145
6273
6401
6529
6657
6785
6913
7041
7169
7297
7425
7553
7681
...

result:

ok answer: 189, maximum: 189

Test #24:

score: 0
Accepted
time: 228ms
memory: 106104kb

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
634
1900
3166
4432
5698
6964
8230
9496
10762
12028
13294
14560
15826
17092
18358
19624
20890
22156
23422
24688
25954
27220
28486
29752
31018
32284
33550
34816
36082
37348
38614
39880
41146
42412
43678
44944
46210
47476
48742
50008
51274
52540
53806
55072
56338
57604
58870
60136
61402
62668
6393...

result:

ok answer: 1896, maximum: 1896

Test #25:

score: 0
Accepted
time: 350ms
memory: 299376kb

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
634
1900
3166
4432
5698
6964
8230
9496
10762
12028
13294
14560
15826
17092
18358
19624
20890
22156
23422
24688
25954
27220
28486
29752
31018
32284
33550
34816
36082
37348
38614
39880
41146
42412
43678
44944
46210
47476
48742
50008
51274
52540
53806
55072
56338
57604
58870
60136
61402
62668
6393...

result:

ok answer: 1896, maximum: 1896

Test #26:

score: 0
Accepted
time: 694ms
memory: 300372kb

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
602
1804
3006
4208
5410
6612
7814
9016
10218
11420
12622
13824
15026
16228
17430
18632
19834
21036
22238
23440
24642
25844
27046
28248
29450
30652
31854
33056
34258
35460
36662
37864
39066
40268
41470
42672
43874
45076
46278
47480
48682
49884
51086
52288
53490
54692
55894
57096
58298
59500
60...

result:

ok answer: 183937, maximum: 183937

Test #27:

score: 0
Accepted
time: 1642ms
memory: 301312kb

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
3
4
19
21
27
33
37
39
41
47
55
56
57
64
73
74
75
77
79
81
87
91
95
97
101
103
105
108
111
115
129
131
133
135
136
137
139
143
145
147
151
154
155
159
167
185
187
191
193
197
198
199
201
207
209
217
221
223
227
231
235
237
243
245
247
257
259
265
269
278
281
307
313
317
319
321
331
334
335
337...

result:

ok answer: 184175, maximum: 184175

Test #28:

score: 0
Accepted
time: 806ms
memory: 300268kb

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
803
1870
3485
4278
5722
6871
7853
9207
10778
11554
12706
14166
15479
16579
17435
18942
20222
21554
22386
23850
25087
26372
27368
28287
29677
30852
32133
33297
34775
35718
36798
37848
39282
40767
41946
42876
44347
45247
46634
47653
48988
49940
51233
52762
53524
54941
55899
57399
58406
59417
60...

result:

ok answer: 183975, maximum: 183975

Test #29:

score: 0
Accepted
time: 1944ms
memory: 300268kb

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
7
9
11
19
21
22
23
27
32
41
45
47
60
63
67
71
73
75
77
79
81
85
87
91
93
95
97
101
105
107
110
115
117
123
125
127
139
140
141
145
151
161
165
179
182
195
199
202
205
206
207
211
218
221
225
228
233
241
255
257
259
265
266
267
271
278
282
297
302
311
317
324
327
329
331
332
349
350
351
355
36...

result:

ok answer: 184156, maximum: 184156

Test #30:

score: 0
Accepted
time: 342ms
memory: 299576kb

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
632
1896
3160
4424
5688
6952
8216
9480
10744
12008
13272
14536
15800
17064
18328
19592
20856
22120
23384
24648
25912
27176
28440
29704
30968
32232
33496
34760
36024
37288
38552
39816
41080
42344
43608
44872
46136
47400
48664
49928
51192
52456
53720
54984
56248
57512
58776
60040
61304
62568
638...

result:

ok answer: 11043, maximum: 11043

Test #31:

score: 0
Accepted
time: 332ms
memory: 299432kb

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
634
1900
3166
4432
5698
6964
8230
9496
10762
12028
13294
14560
15826
17092
18358
19624
20890
22156
23422
24688
25954
27220
28486
29752
31018
32284
33550
34816
36082
37348
38614
39880
41146
42412
43678
44944
46210
47476
48742
50008
51274
52540
53806
55072
56338
57604
58870
60136
61402
62668
6393...

result:

ok answer: 4770, maximum: 4770

Test #32:

score: 0
Accepted
time: 916ms
memory: 298720kb

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
998
2000
2502
3504
4506
5508
6510
7512
8514
9516
10518
11520
12522
13524
14526
15528
16530
17532
18534
19536
20538
21540
22542
23544
24546
25548
26550
27552
28554
29556
30558
31560
32562
33564
34566
35568
36570
37572
38574
39576
40578
41580
42582
43584
44586
45588
46590
47592
48594
49596
50598
...

result:

ok answer: 1505, maximum: 1505

Test #33:

score: 0
Accepted
time: 613ms
memory: 299276kb

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
1198
2400
3002
4204
5406
6608
7810
9012
10214
11416
12618
13820
15022
16224
17426
18628
19830
21032
22234
23436
24638
25840
27042
28244
29446
30648
31850
33052
34254
35456
36658
37860
39062
40264
41466
42668
43870
45072
46274
47476
48678
49880
51082
52284
53486
54688
55890
57092
58294
59496
606...

result:

ok answer: 1804, maximum: 1804

Test #34:

score: 0
Accepted
time: 1113ms
memory: 296548kb

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
900
1352
2254
3156
4058
4960
5862
6764
7666
8568
9470
10372
11274
12176
13078
13980
14882
15784
16686
17588
18490
19392
20294
21196
22098
23000
23902
24804
25706
26608
27510
28412
29314
30216
31118
32020
32922
33824
34726
35628
36530
37432
38334
39236
40138
41040
41942
42844
43746
44648
45550
4...

result:

ok answer: 1356, maximum: 1356

Test #35:

score: 0
Accepted
time: 1094ms
memory: 296056kb

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
352
1054
1756
2458
3160
3862
4564
5266
5968
6670
7372
8074
8776
9478
10180
10882
11584
12286
12988
13690
14392
15094
15796
16498
17200
17902
18604
19306
20008
20710
21412
22114
22816
23518
24220
24922
25624
26326
27028
27730
28432
29134
29836
30538
31240
31942
32644
33346
34048
34750
35452
3615...

result:

ok answer: 1051, maximum: 1051

Test #36:

score: 0
Accepted
time: 888ms
memory: 297024kb

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
726
1810
2847
4142
5479
6052
7650
8775
9379
10706
12092
13104
13876
14936
16437
17529
18635
19725
20417
21810
22606
23801
25039
25915
27137
28493
29349
30685
31683
32747
33816
35009
36267
36886
38062
39335
40531
41637
42660
43989
44677
46157
47070
48374
49267
50478
51336
52555
53359
54805
55716...

result:

ok answer: 1651, maximum: 1651

Test #37:

score: 0
Accepted
time: 2534ms
memory: 296232kb

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
3
7
9
15
45
47
57
71
99
109
123
129
145
211
221
237
255
275
307
309
379
401
407
419
437
447
487
489
519
543
589
597
607
617
627
631
649
687
693
701
739
741
767
773
775
809
821
825
831
835
839
841
875
881
895
903
911
931
939
947
963
969
987
1027
1055
1067
1077
1095
1111
1141
1153
1157
1159
1199
...

result:

ok answer: 1365, maximum: 1365

Test #38:

score: 0
Accepted
time: 751ms
memory: 296748kb

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
502
1504
2506
3508
4510
5512
6514
7516
8518
9520
10522
11524
12526
13528
14530
15532
16534
17536
18538
19540
20542
21544
22546
23548
24550
25552
26554
27556
28558
29560
30562
31564
32566
33568
34570
35572
36574
37576
38578
39580
40582
41584
42586
43588
44590
45592
46594
47596
48598
49600
50602
...

result:

ok answer: 1515, maximum: 1515

Test #39:

score: 0
Accepted
time: 764ms
memory: 297172kb

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:

2565
806
1612
2418
3224
4030
4836
5642
6448
7254
8060
8866
9672
10478
11284
12090
12896
13702
14508
15314
16120
16926
17732
18538
19344
20150
20956
21762
22568
23374
24180
24986
25792
26598
27404
28210
29016
29822
30628
31434
32240
33046
33852
34658
35464
36270
37076
37882
38688
39494
40300
41106
41...

result:

ok answer: 2565, maximum: 2565

Test #40:

score: 0
Accepted
time: 344ms
memory: 297368kb

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:

2998
1000
2000
3000
4000
5000
6000
7000
8000
9000
10000
11000
12000
13000
14000
15000
16000
17000
18000
19000
20000
21000
22000
23000
24000
25000
26000
27000
28000
29000
30000
31000
32000
33000
34000
35000
36000
37000
38000
39000
40000
41000
42000
43000
44000
45000
46000
47000
48000
49000
50000
5100...

result:

ok answer: 2998, maximum: 2998

Test #41:

score: 0
Accepted
time: 3542ms
memory: 297252kb

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:

2882
13
19
31
59
73
75
99
101
109
111
113
119
123
129
131
143
149
153
157
163
173
187
189
193
199
205
217
221
245
251
261
273
275
315
353
355
363
365
367
369
381
385
389
391
403
407
427
429
431
433
441
443
445
455
461
465
479
489
493
503
505
507
511
541
571
573
577
581
583
593
603
635
641
647
657
66...

result:

ok answer: 2882, maximum: 2998

Test #42:

score: 0
Accepted
time: 2176ms
memory: 297124kb

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:

2710
901
1802
2703
3604
4505
5406
6307
7208
8109
9010
9911
10812
11713
12614
13515
14416
15317
16218
17119
18020
18921
19822
20723
21624
22525
23426
24327
25228
26129
27030
27931
28832
29733
30634
31535
32436
33337
34238
35139
36040
36941
37842
38743
39644
40545
41446
42347
43248
44149
45050
45951
4...

result:

ok answer: 2710, maximum: 2710

Test #43:

score: 0
Accepted
time: 3902ms
memory: 297320kb

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:

2693
17
21
39
43
57
59
63
75
95
97
103
107
113
115
131
217
221
235
237
249
259
275
285
287
313
316
339
343
345
359
361
367
383
413
433
513
519
575
587
591
595
601
611
613
623
625
629
663
699
721
729
731
749
781
789
803
815
821
827
855
859
867
871
873
885
887
907
923
927
929
933
947
965
971
973
979
9...

result:

ok answer: 2693, maximum: 2800

Test #44:

score: 0
Accepted
time: 3524ms
memory: 297320kb

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:

2622
7
11
13
15
17
25
29
49
61
65
77
93
95
111
117
123
129
131
151
155
167
185
193
195
199
207
221
225
233
239
257
259
263
273
277
279
297
299
301
319
321
327
343
345
353
371
373
377
379
381
389
391
395
399
401
405
407
417
455
457
503
505
539
541
543
553
559
565
603
609
611
623
635
651
657
665
695
6...

result:

ok answer: 2622, maximum: 2750

Test #45:

score: 0
Accepted
time: 3818ms
memory: 297180kb

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:

2427
9
17
19
33
63
65
71
83
85
89
99
105
117
125
133
135
139
143
159
163
165
195
201
205
217
219
222
227
233
235
237
239
241
245
261
273
279
293
297
301
303
311
327
337
369
375
379
381
393
397
403
413
427
431
439
445
477
509
511
515
517
519
521
541
593
597
623
631
641
663
687
719
727
729
737
803
813...

result:

ok answer: 2427, maximum: 2530

Test #46:

score: 0
Accepted
time: 2491ms
memory: 296744kb

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:

2401
801
1602
2403
3204
4005
4806
5607
6408
7209
8010
8811
9612
10413
11214
12015
12816
13617
14418
15219
16020
16821
17622
18423
19224
20025
20826
21627
22428
23229
24030
24831
25632
26433
27234
28035
28836
29637
30438
31239
32040
32841
33642
34443
35244
36045
36846
37647
38448
39249
40050
40851
41...

result:

ok answer: 2401, maximum: 2401

Test #47:

score: 0
Accepted
time: 3521ms
memory: 296540kb

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:

1955
621
1242
1863
2484
3105
3726
4347
4968
5589
6210
6831
7452
8073
8694
9315
9936
10557
11178
11799
12420
13041
13662
14283
14904
15525
16146
16767
17388
18009
18630
19251
19872
20493
21114
21735
22356
22977
23598
24219
24840
25461
26082
26703
27324
27369
28566
29187
29808
30429
31050
31671
32292
...

result:

ok answer: 1955, maximum: 1960

Test #48:

score: 0
Accepted
time: 170ms
memory: 308604kb

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: 1316ms
memory: 309340kb

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
1
2
3
6
9
14
15
16
17
18
20
21
22
23
24
28
29
31
32
35
36
39
41
43
46
47
48
49
50
53
54
57
58
59
60
61
64
68
69
73
75
77
78
79
80
87
89
91
92
93
94
96
98
102
105
106
110
112
113
115
118
119
124
126
128
130
131
132
134
137
138
139
140
141
142
144
145
147
148
149
151
153
154
159
160
162
163
166...

result:

ok answer: 998001, maximum: 998001

Test #50:

score: 0
Accepted
time: 2533ms
memory: 309432kb

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
1
3
5
9
10
11
14
17
19
23
24
25
26
28
29
31
33
34
35
36
38
40
44
54
56
58
59
62
66
67
69
70
71
73
74
75
77
79
81
82
85
89
90
93
96
97
99
101
105
106
107
108
109
111
112
116
118
119
121
123
124
127
133
142
145
147
149
150
151
152
159
164
165
166
167
169
170
174
176
177
179
182
183
186
187
188...

result:

ok answer: 1000000, maximum: 1000000

Test #51:

score: 0
Accepted
time: 3245ms
memory: 305356kb

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:

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

result:

ok answer: 665423, maximum: 666667

Test #52:

score: 0
Accepted
time: 3575ms
memory: 305580kb

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:

660909
4
6
7
8
16
19
26
34
38
39
41
43
44
46
47
50
51
53
56
58
59
61
70
75
78
81
84
87
92
95
96
97
101
103
105
106
108
112
114
116
118
122
127
128
134
136
141
145
147
157
158
160
162
163
164
169
174
178
180
181
183
187
192
194
196
197
203
205
207
211
217
218
220
221
229
232
233
238
239
241
242
243
2...

result:

ok answer: 660909, maximum: 666667

Test #53:

score: 0
Accepted
time: 3704ms
memory: 305944kb

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:

654424
2
6
7
13
14
20
22
23
26
31
33
35
38
41
44
46
47
50
51
52
53
56
57
60
61
72
73
74
76
77
81
88
89
93
98
100
101
103
104
108
111
112
115
117
118
125
129
130
132
137
138
140
142
144
145
148
150
152
158
162
163
165
169
171
173
174
178
181
184
186
193
194
198
199
202
209
214
215
216
224
226
230
231...

result:

ok answer: 654424, maximum: 666667

Test #54:

score: 0
Accepted
time: 3920ms
memory: 308500kb

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:

855998
5
8
9
11
13
14
17
22
23
24
27
29
30
33
39
41
43
45
46
49
56
59
63
64
66
70
71
73
78
79
80
81
84
85
87
89
90
92
93
94
101
102
107
111
113
115
119
123
127
128
129
130
132
133
136
137
138
140
143
148
150
153
154
155
157
158
163
166
169
172
173
174
177
179
181
182
183
187
188
193
202
204
207
209
...

result:

ok answer: 855998, maximum: 866667

Test #55:

score: 0
Accepted
time: 198ms
memory: 297864kb

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
1
2
3
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
10...

result:

ok answer: 1999995, maximum: 1999995

Test #56:

score: -100
Time Limit Exceeded

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:


result: