QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#619252#9186. Circle Passingjxy2012#100 ✓40ms7184kbC++23974b2024-10-07 13:39:152024-10-07 13:39:15

詳細信息

Subtask #1:

score: 14
Accepted

Test #1:

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

input:

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

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 20000 lines

Test #2:

score: 14
Accepted
time: 3ms
memory: 3792kb

input:

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

output:

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

result:

ok 20000 lines

Test #3:

score: 14
Accepted
time: 3ms
memory: 3792kb

input:

100 1 20000
99
99 91
99 14
99 35
99 168
99 13
99 177
99 121
99 154
99 18
99 94
99 165
99 107
99 88
99 98
99 126
99 166
99 90
99 198
99 48
99 23
99 46
99 131
99 21
99 123
99 92
99 137
99 128
99 128
99 18
99 80
99 10
99 51
99 186
99 88
99 198
99 142
99 54
99 116
99 2
99 185
99 169
99 56
99 135
99 148
...

output:

8
16
37
32
15
23
22
46
20
5
35
8
11
1
27
34
9
2
50
25
48
32
23
24
7
38
29
29
20
19
12
48
14
11
2
43
45
17
4
15
31
43
36
49
39
40
22
17
25
32
39
24
3
9
24
7
10
24
37
4
28
30
37
5
18
19
44
9
49
42
47
10
8
1
40
45
44
26
49
27
46
17
8
25
20
15
11
35
18
41
12
34
37
43
14
44
42
26
40
41
26
45
5
4
3
41
44
...

result:

ok 20000 lines

Test #4:

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

input:

1000 1 1
694
694 891

output:

197

result:

ok single line: '197'

Test #5:

score: 14
Accepted
time: 4ms
memory: 3788kb

input:

100000 1 20000
93018
93018 92828
93018 124203
93018 180530
93018 117244
93018 32089
93018 47616
93018 56972
93018 2771
93018 166821
93018 82000
93018 53651
93018 152580
93018 146287
93018 161214
93018 124947
93018 67461
93018 29407
93018 174059
93018 108598
93018 36288
93018 130879
93018 197004
9301...

output:

190
31185
12489
24226
39072
45402
36046
9754
26198
11018
39367
40439
46732
31805
31929
25557
36390
18960
15580
43271
37861
3987
1682
16615
25363
11592
25989
47041
2369
35703
6132
26409
5626
9187
3259
18048
28989
39551
33325
5540
29180
15338
32087
9180
25474
45192
49252
28286
46436
10665
7270
32861
6...

result:

ok 20000 lines

Test #6:

score: 14
Accepted
time: 4ms
memory: 3820kb

input:

500000000 1 20000
0
0 912923202
0 578238095
0 603174293
0 263466847
0 418742264
0 93849323
0 192816093
0 175124509
0 192375412
0 65677291
0 314991283
0 421453458
0 235928525
0 645400602
0 496209395
0 214124568
0 36341140
0 648267237
0 683585873
0 965901380
0 711062740
0 65480623
0 822215431
0 895574...

output:

87076798
78238096
103174294
236533154
81257737
93849323
192816093
175124509
192375412
65677291
185008718
78546543
235928525
145400603
3790606
214124568
36341140
148267238
183585874
34098620
211062741
65480623
177784569
104425868
202296888
27011844
110368095
15548777
80603127
221978350
54464776
22526...

result:

ok 20000 lines

Test #7:

score: 14
Accepted
time: 5ms
memory: 4076kb

input:

500000000 1 20000
52007973
52007973 87413823
52007973 247004975
52007973 884551041
52007973 161702009
52007973 892694089
52007973 632824937
52007973 177843603
52007973 313022454
52007973 625221799
52007973 634707855
52007973 589915468
52007973 702833391
52007973 957683052
52007973 84410910
52007973 ...

output:

35405850
194997002
167456932
109694036
159313884
80816965
125835630
238985520
73213827
82699883
37907496
150825419
94324921
32402937
4769622
165378271
202601759
25897974
101247495
232601224
129969454
134165089
222107881
154018264
83688917
193733976
2310458
108381970
209429847
245322356
127109145
248...

result:

ok 20000 lines

Test #8:

score: 14
Accepted
time: 5ms
memory: 3792kb

input:

500000000 1 20000
268203494
268203494 628297992
268203494 360304257
268203494 965307290
268203494 478270227
268203494 184713809
268203494 602949889
268203494 856591419
268203494 451463558
268203494 566210210
268203494 620395684
268203494 397827048
268203494 982753046
268203494 771712581
268203494 70...

output:

139905503
92100763
197103797
210066733
83489685
165253606
88387926
183260064
201993285
147807811
129623554
214549553
3509088
61014113
208655602
165098644
190758000
97786170
132226477
227745765
132020400
2640713
223740448
127711827
226503809
205321315
201825223
66033023
25751046
88553
171160149
24636...

result:

ok 20000 lines

Test #9:

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

input:

500000000 1 20000
188717824
188717824 296338508
188717824 612677479
188717824 215911204
188717824 276694321
188717824 810184200
188717824 65884877
188717824 77273999
188717824 309536692
188717824 930212412
188717824 50660607
188717824 797560592
188717824 264531784
188717824 46380654
188717824 628913...

output:

107620684
76040346
27193380
87976497
121466377
122832947
111443825
120818868
241494589
138057217
108842769
75813960
142337170
59804159
206795473
52702017
79476529
215584824
200251320
227956419
190945748
104091573
144616854
145346962
17495834
67689077
54486995
119848287
35971689
224697124
114644802
2...

result:

ok 20000 lines

Test #10:

score: 14
Accepted
time: 5ms
memory: 3788kb

input:

500000000 1 20000
440287253
440287253 865756918
440287253 346988225
440287253 713601177
440287253 371434297
440287253 887727641
440287253 953472596
440287253 389562860
440287253 624961030
440287253 298227534
440287253 813860613
440287253 415399403
440287253 941974177
440287253 321514752
440287253 30...

output:

74530336
93299028
226686077
68852956
52559613
13185344
50724393
184673777
142059719
126426641
24887850
1686925
118772501
135455899
82821314
145582027
202537317
181960515
122917192
188248617
173783328
114030885
10389717
88246345
49446258
93132168
224691138
2666784
202434840
12640616
189236830
1234962...

result:

ok 20000 lines

Test #11:

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

input:

4 1 5
1
1 4
1 5
1 7
1 2
1 6

output:

2
1
2
1
2

result:

ok 5 lines

Test #12:

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

input:

6 1 3
5
5 7
5 1
5 11

output:

2
3
1

result:

ok 3 lines

Subtask #2:

score: 20
Accepted

Test #13:

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

input:

1000 1 1
694
694 891

output:

197

result:

ok single line: '197'

Test #14:

score: 20
Accepted
time: 1ms
memory: 4068kb

input:

326 1 1000
166
173 18
580 117
400 211
298 130
237 56
537 628
276 277
555 630
8 488
616 592
98 358
541 159
456 360
495 276
371 203
551 402
376 539
524 209
368 263
493 625
87 206
468 369
209 146
358 540
127 76
331 15
200 3
623 453
277 410
63 83
128 628
502 476
243 551
316 193
116 257
421 594
158 494
2...

output:

155
138
138
168
181
91
1
75
163
24
203
57
96
114
159
149
163
76
105
132
119
99
63
182
51
313
197
170
133
20
152
26
137
123
141
173
11
128
192
47
156
40
100
202
32
46
6
141
120
89
168
117
213
53
24
147
113
156
26
42
117
110
195
113
77
154
135
200
316
192
233
87
153
163
159
13
160
162
99
111
157
62
11...

result:

ok 1000 lines

Test #15:

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

input:

397 1 1000
103
256 424
792 670
620 683
228 717
248 713
361 163
28 41
149 102
692 531
493 173
353 70
236 788
243 116
771 236
228 528
780 604
504 656
497 487
569 297
134 339
162 42
569 644
443 192
494 192
639 267
329 528
685 617
783 193
358 712
316 636
539 383
756 772
385 46
293 401
548 565
122 712
61...

output:

168
122
63
305
329
198
13
47
161
78
181
242
127
259
154
176
152
10
264
193
120
75
147
96
304
199
68
204
328
320
156
16
173
108
17
204
155
189
97
166
19
47
282
35
196
211
223
242
292
183
290
114
139
194
169
22
112
11
41
132
143
72
130
31
289
202
383
209
257
261
16
116
69
131
102
109
267
13
77
54
246
...

result:

ok 1000 lines

Test #16:

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

input:

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

output:

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

result:

ok 1000 lines

Test #17:

score: 20
Accepted
time: 1ms
memory: 4076kb

input:

81 75 1000
0 1 2 3 4 5 6 7 8 10 11 12 14 15 16 17 18 19 21 22 24 25 26 27 28 29 30 31 32 33 34 35 36 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
74 101
35 101
8 150
74 133
11 68
17 70
132 29
46 53
1 59
59 132
71 37
67 ...

output:

27
16
20
23
25
29
23
7
24
9
34
2
28
14
35
25
31
7
7
30
31
7
27
8
31
24
6
36
38
27
4
30
10
24
28
18
19
18
33
7
41
33
33
23
1
35
19
23
28
32
32
5
16
40
18
10
7
31
12
15
17
41
3
6
4
32
39
22
16
21
10
16
8
30
16
15
32
39
11
13
15
1
28
6
16
3
8
17
19
19
2
24
9
25
3
5
4
7
37
33
10
31
21
37
39
23
19
14
11
...

result:

ok 1000 lines

Test #18:

score: 20
Accepted
time: 1ms
memory: 3784kb

input:

109 12 1000
0 35 39 43 63 69 75 85 86 95 100 106
164 44
174 160
139 180
112 143
164 88
216 102
159 89
133 2
214 107
119 140
116 183
73 15
135 189
180 108
216 11
192 118
32 84
70 31
81 75
135 156
80 16
199 80
120 90
90 183
145 29
117 211
16 149
200 34
94 134
69 44
188 70
205 104
123 84
180 212
159 83...

output:

14
14
41
31
34
6
40
27
3
21
43
52
54
38
13
36
52
39
6
21
46
11
30
17
8
16
25
52
40
25
10
9
39
32
34
52
46
35
15
8
54
32
12
41
22
40
16
40
37
17
42
39
27
51
22
42
24
6
5
44
8
18
31
37
38
24
37
49
35
10
12
18
16
4
7
32
13
11
28
50
47
3
24
14
38
11
54
19
17
36
39
34
26
16
26
15
51
44
8
25
21
47
9
20
44...

result:

ok 1000 lines

Test #19:

score: 20
Accepted
time: 1ms
memory: 3824kb

input:

299 207 1000
2 5 6 7 8 11 13 15 16 17 20 23 24 26 28 31 32 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 53 54 55 56 57 58 59 60 61 64 65 66 67 68 70 74 75 77 78 81 83 84 85 86 88 89 90 91 92 93 95 96 97 98 99 101 102 103 104 105 106 107 109 111 112 114 115 116 117 119 121 122 123 124 125 127 1...

output:

8
120
22
4
82
136
2
17
112
26
56
150
61
37
69
21
57
25
39
67
93
115
104
138
140
90
122
41
50
40
107
15
9
98
13
35
99
99
106
10
59
38
57
122
40
18
23
35
109
57
47
2
37
14
107
8
101
58
131
71
12
133
6
148
88
34
106
91
101
52
62
95
51
67
45
2
117
118
112
4
47
44
10
119
17
27
110
62
55
38
144
29
111
92
...

result:

ok 1000 lines

Test #20:

score: 20
Accepted
time: 1ms
memory: 3804kb

input:

1000 43 1000
25 32 44 93 101 141 160 171 185 188 212 227 236 253 259 274 351 355 440 446 450 466 573 577 586 612 644 645 647 652 657 684 717 756 790 801 838 863 939 948 957 979 989
1065 974
1468 1131
674 913
1101 1445
1636 1608
749 433
74 1246
786 450
189 296
1655 1531
1668 839
222 1270
201 198
1156...

output:

91
337
239
344
28
316
173
336
107
124
172
49
3
66
266
294
402
122
24
480
312
91
138
142
324
247
111
429
278
103
170
10
253
391
169
302
322
231
441
488
279
129
412
484
109
383
15
125
151
336
87
206
113
114
205
437
169
330
75
485
45
322
146
306
34
360
273
16
254
385
50
176
173
469
439
196
447
184
430
...

result:

ok 1000 lines

Test #21:

score: 20
Accepted
time: 1ms
memory: 4044kb

input:

1000 816 1000
0 1 2 3 4 5 6 7 9 10 12 13 14 15 16 18 19 20 21 23 24 25 26 27 28 29 30 32 33 35 36 37 38 39 40 41 42 43 46 47 50 51 52 54 55 56 57 58 59 61 62 63 64 65 66 67 69 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 94 95 97 98 99 100 101 102 103 104 105 106 107 108 109 110...

output:

490
21
108
53
395
499
379
261
459
198
294
301
88
490
76
143
473
78
472
337
450
342
283
270
210
106
193
224
87
45
104
358
90
480
259
300
271
229
370
364
441
41
243
483
482
261
125
250
148
332
232
19
404
130
383
106
57
338
117
41
111
402
127
134
219
432
57
451
438
383
341
80
50
133
356
456
384
40
93
3...

result:

ok 1000 lines

Test #22:

score: 20
Accepted
time: 1ms
memory: 3784kb

input:

1000 6 1000
0 203 277 537 759 922
1160 366
86 1181
418 53
1094 1509
725 1777
1162 1629
1551 1800
468 239
1928 1235
1783 267
412 232
1700 554
1254 126
408 809
912 612
707 362
1076 648
335 700
22 1030
1463 1333
1009 391
1656 1119
1016 1476
589 1107
1060 1098
1273 236
47 254
794 11
819 480
372 523
1250...

output:

207
140
365
415
53
467
249
229
308
484
180
181
129
401
300
345
428
365
53
130
383
464
460
483
38
46
207
218
339
151
202
135
95
385
421
247
307
171
367
443
408
474
205
49
456
22
437
268
256
387
72
483
248
473
28
497
492
432
450
228
436
479
469
473
431
342
59
296
227
475
26
78
78
297
45
447
314
137
52...

result:

ok 1000 lines

Test #23:

score: 20
Accepted
time: 1ms
memory: 3784kb

input:

1000 6 1000
104 432 500 801 975 998
798 1474
376 497
1158 140
9 1761
512 1397
1649 1771
1128 1575
1604 1628
1681 144
1915 1174
933 1726
416 389
699 1538
1830 1755
237 302
374 461
27 1678
75 1761
213 886
1860 106
1300 361
870 391
1752 1286
1593 1013
617 257
343 345
975 106
1472 1708
1646 1682
1204 83...

output:

325
121
91
248
116
122
447
24
463
260
208
27
238
75
65
87
349
314
328
246
204
479
466
421
360
2
132
236
36
370
149
86
205
343
67
321
261
388
60
220
157
159
456
424
458
273
91
181
375
316
222
373
135
210
469
240
8
407
190
49
245
369
277
143
321
184
152
297
164
243
151
313
215
111
200
456
395
43
202
2...

result:

ok 1000 lines

Test #24:

score: 20
Accepted
time: 1ms
memory: 3784kb

input:

1000 76 1000
1 10 28 32 81 92 99 108 131 136 146 167 177 179 191 199 235 240 243 267 268 273 296 324 343 371 383 388 398 430 442 453 460 472 504 505 539 541 554 575 584 598 618 653 660 670 701 721 724 727 729 731 746 782 799 802 817 826 827 852 859 863 869 875 879 892 899 917 920 930 945 951 954 971...

output:

187
283
321
273
89
396
356
332
454
166
335
331
162
272
432
229
33
360
372
425
113
316
106
202
493
110
191
366
302
412
96
12
236
81
348
430
317
423
240
93
334
471
314
113
308
500
41
218
436
361
21
411
68
342
136
185
398
69
456
475
444
248
289
464
243
450
28
71
261
29
70
331
233
63
120
53
65
428
61
15...

result:

ok 1000 lines

Test #25:

score: 20
Accepted
time: 1ms
memory: 4048kb

input:

1000 86 1000
13 39 42 43 47 52 62 66 84 85 112 121 144 147 158 168 181 193 198 206 214 224 237 245 266 283 289 299 310 318 339 341 352 378 395 403 415 421 423 435 452 454 483 500 505 507 513 515 530 535 544 562 566 589 591 606 617 626 633 643 690 714 722 727 731 738 750 760 770 776 790 822 829 846 8...

output:

450
148
280
215
462
237
200
296
215
105
128
178
262
141
461
27
478
190
36
297
494
183
84
344
133
160
481
476
88
62
279
15
268
485
481
160
152
255
391
78
169
76
135
480
400
294
133
465
349
291
167
448
452
208
496
279
232
417
353
413
209
133
463
299
329
53
253
34
233
37
155
234
299
32
50
474
67
98
489...

result:

ok 1000 lines

Test #26:

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

input:

1000 273 10
0 1 2 5 11 12 16 21 24 25 26 27 32 34 36 38 40 41 42 43 47 50 51 60 62 63 66 68 81 82 90 102 103 104 112 117 120 121 123 127 136 137 140 151 155 157 163 170 173 175 179 182 187 189 190 192 195 197 199 202 206 215 216 217 221 225 230 235 236 240 241 242 246 251 254 258 263 275 286 288 289...

output:

144
473
90
261
241
68
50
218
99
339

result:

ok 10 lines

Test #27:

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

input:

1000 189 100
0 1 8 11 14 17 19 20 39 41 46 48 78 79 83 90 92 93 95 112 125 129 130 133 134 138 142 144 147 152 156 163 166 168 182 184 190 191 194 202 204 207 212 222 231 235 236 238 242 249 253 268 273 289 292 304 305 306 312 314 321 329 338 341 345 346 351 359 364 389 393 396 401 402 409 414 416 4...

output:

182
474
218
35
224
428
57
100
153
450
44
96
27
176
320
14
277
226
303
78
240
277
458
414
5
243
111
130
157
157
347
394
137
413
333
39
92
462
124
390
285
46
481
34
413
67
320
378
76
86
68
135
128
254
254
8
253
360
71
204
108
32
85
13
106
191
122
453
493
378
218
149
387
371
61
266
273
104
25
337
410
4...

result:

ok 100 lines

Test #28:

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

input:

2 1 5
1
0 1
0 3
0 1
0 3
0 1

output:

1
1
1
1
1

result:

ok 5 lines

Test #29:

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

input:

4 1 5
1
1 4
1 5
1 7
1 2
1 6

output:

2
1
2
1
2

result:

ok 5 lines

Test #30:

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

input:

6 1 3
5
5 7
5 1
5 11

output:

2
3
1

result:

ok 3 lines

Test #31:

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

input:

4 2 4
2 3
0 2
0 3
0 6
0 7

output:

2
2
2
1

result:

ok 4 lines

Test #32:

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

input:

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

output:

1
3
3
3
2

result:

ok 5 lines

Subtask #3:

score: 22
Accepted

Dependency #2:

100%
Accepted

Test #33:

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

input:

1000 1 1
694
694 891

output:

197

result:

ok single line: '197'

Test #34:

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

input:

326 1 1000
166
173 18
580 117
400 211
298 130
237 56
537 628
276 277
555 630
8 488
616 592
98 358
541 159
456 360
495 276
371 203
551 402
376 539
524 209
368 263
493 625
87 206
468 369
209 146
358 540
127 76
331 15
200 3
623 453
277 410
63 83
128 628
502 476
243 551
316 193
116 257
421 594
158 494
2...

output:

155
138
138
168
181
91
1
75
163
24
203
57
96
114
159
149
163
76
105
132
119
99
63
182
51
313
197
170
133
20
152
26
137
123
141
173
11
128
192
47
156
40
100
202
32
46
6
141
120
89
168
117
213
53
24
147
113
156
26
42
117
110
195
113
77
154
135
200
316
192
233
87
153
163
159
13
160
162
99
111
157
62
11...

result:

ok 1000 lines

Test #35:

score: 22
Accepted
time: 1ms
memory: 3776kb

input:

397 1 1000
103
256 424
792 670
620 683
228 717
248 713
361 163
28 41
149 102
692 531
493 173
353 70
236 788
243 116
771 236
228 528
780 604
504 656
497 487
569 297
134 339
162 42
569 644
443 192
494 192
639 267
329 528
685 617
783 193
358 712
316 636
539 383
756 772
385 46
293 401
548 565
122 712
61...

output:

168
122
63
305
329
198
13
47
161
78
181
242
127
259
154
176
152
10
264
193
120
75
147
96
304
199
68
204
328
320
156
16
173
108
17
204
155
189
97
166
19
47
282
35
196
211
223
242
292
183
290
114
139
194
169
22
112
11
41
132
143
72
130
31
289
202
383
209
257
261
16
116
69
131
102
109
267
13
77
54
246
...

result:

ok 1000 lines

Test #36:

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

input:

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

output:

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

result:

ok 1000 lines

Test #37:

score: 22
Accepted
time: 1ms
memory: 3800kb

input:

81 75 1000
0 1 2 3 4 5 6 7 8 10 11 12 14 15 16 17 18 19 21 22 24 25 26 27 28 29 30 31 32 33 34 35 36 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
74 101
35 101
8 150
74 133
11 68
17 70
132 29
46 53
1 59
59 132
71 37
67 ...

output:

27
16
20
23
25
29
23
7
24
9
34
2
28
14
35
25
31
7
7
30
31
7
27
8
31
24
6
36
38
27
4
30
10
24
28
18
19
18
33
7
41
33
33
23
1
35
19
23
28
32
32
5
16
40
18
10
7
31
12
15
17
41
3
6
4
32
39
22
16
21
10
16
8
30
16
15
32
39
11
13
15
1
28
6
16
3
8
17
19
19
2
24
9
25
3
5
4
7
37
33
10
31
21
37
39
23
19
14
11
...

result:

ok 1000 lines

Test #38:

score: 22
Accepted
time: 1ms
memory: 3788kb

input:

109 12 1000
0 35 39 43 63 69 75 85 86 95 100 106
164 44
174 160
139 180
112 143
164 88
216 102
159 89
133 2
214 107
119 140
116 183
73 15
135 189
180 108
216 11
192 118
32 84
70 31
81 75
135 156
80 16
199 80
120 90
90 183
145 29
117 211
16 149
200 34
94 134
69 44
188 70
205 104
123 84
180 212
159 83...

output:

14
14
41
31
34
6
40
27
3
21
43
52
54
38
13
36
52
39
6
21
46
11
30
17
8
16
25
52
40
25
10
9
39
32
34
52
46
35
15
8
54
32
12
41
22
40
16
40
37
17
42
39
27
51
22
42
24
6
5
44
8
18
31
37
38
24
37
49
35
10
12
18
16
4
7
32
13
11
28
50
47
3
24
14
38
11
54
19
17
36
39
34
26
16
26
15
51
44
8
25
21
47
9
20
44...

result:

ok 1000 lines

Test #39:

score: 22
Accepted
time: 1ms
memory: 3848kb

input:

299 207 1000
2 5 6 7 8 11 13 15 16 17 20 23 24 26 28 31 32 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 53 54 55 56 57 58 59 60 61 64 65 66 67 68 70 74 75 77 78 81 83 84 85 86 88 89 90 91 92 93 95 96 97 98 99 101 102 103 104 105 106 107 109 111 112 114 115 116 117 119 121 122 123 124 125 127 1...

output:

8
120
22
4
82
136
2
17
112
26
56
150
61
37
69
21
57
25
39
67
93
115
104
138
140
90
122
41
50
40
107
15
9
98
13
35
99
99
106
10
59
38
57
122
40
18
23
35
109
57
47
2
37
14
107
8
101
58
131
71
12
133
6
148
88
34
106
91
101
52
62
95
51
67
45
2
117
118
112
4
47
44
10
119
17
27
110
62
55
38
144
29
111
92
...

result:

ok 1000 lines

Test #40:

score: 22
Accepted
time: 1ms
memory: 4044kb

input:

1000 43 1000
25 32 44 93 101 141 160 171 185 188 212 227 236 253 259 274 351 355 440 446 450 466 573 577 586 612 644 645 647 652 657 684 717 756 790 801 838 863 939 948 957 979 989
1065 974
1468 1131
674 913
1101 1445
1636 1608
749 433
74 1246
786 450
189 296
1655 1531
1668 839
222 1270
201 198
1156...

output:

91
337
239
344
28
316
173
336
107
124
172
49
3
66
266
294
402
122
24
480
312
91
138
142
324
247
111
429
278
103
170
10
253
391
169
302
322
231
441
488
279
129
412
484
109
383
15
125
151
336
87
206
113
114
205
437
169
330
75
485
45
322
146
306
34
360
273
16
254
385
50
176
173
469
439
196
447
184
430
...

result:

ok 1000 lines

Test #41:

score: 22
Accepted
time: 1ms
memory: 3804kb

input:

1000 816 1000
0 1 2 3 4 5 6 7 9 10 12 13 14 15 16 18 19 20 21 23 24 25 26 27 28 29 30 32 33 35 36 37 38 39 40 41 42 43 46 47 50 51 52 54 55 56 57 58 59 61 62 63 64 65 66 67 69 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 94 95 97 98 99 100 101 102 103 104 105 106 107 108 109 110...

output:

490
21
108
53
395
499
379
261
459
198
294
301
88
490
76
143
473
78
472
337
450
342
283
270
210
106
193
224
87
45
104
358
90
480
259
300
271
229
370
364
441
41
243
483
482
261
125
250
148
332
232
19
404
130
383
106
57
338
117
41
111
402
127
134
219
432
57
451
438
383
341
80
50
133
356
456
384
40
93
3...

result:

ok 1000 lines

Test #42:

score: 22
Accepted
time: 1ms
memory: 3792kb

input:

1000 6 1000
0 203 277 537 759 922
1160 366
86 1181
418 53
1094 1509
725 1777
1162 1629
1551 1800
468 239
1928 1235
1783 267
412 232
1700 554
1254 126
408 809
912 612
707 362
1076 648
335 700
22 1030
1463 1333
1009 391
1656 1119
1016 1476
589 1107
1060 1098
1273 236
47 254
794 11
819 480
372 523
1250...

output:

207
140
365
415
53
467
249
229
308
484
180
181
129
401
300
345
428
365
53
130
383
464
460
483
38
46
207
218
339
151
202
135
95
385
421
247
307
171
367
443
408
474
205
49
456
22
437
268
256
387
72
483
248
473
28
497
492
432
450
228
436
479
469
473
431
342
59
296
227
475
26
78
78
297
45
447
314
137
52...

result:

ok 1000 lines

Test #43:

score: 22
Accepted
time: 1ms
memory: 4100kb

input:

1000 6 1000
104 432 500 801 975 998
798 1474
376 497
1158 140
9 1761
512 1397
1649 1771
1128 1575
1604 1628
1681 144
1915 1174
933 1726
416 389
699 1538
1830 1755
237 302
374 461
27 1678
75 1761
213 886
1860 106
1300 361
870 391
1752 1286
1593 1013
617 257
343 345
975 106
1472 1708
1646 1682
1204 83...

output:

325
121
91
248
116
122
447
24
463
260
208
27
238
75
65
87
349
314
328
246
204
479
466
421
360
2
132
236
36
370
149
86
205
343
67
321
261
388
60
220
157
159
456
424
458
273
91
181
375
316
222
373
135
210
469
240
8
407
190
49
245
369
277
143
321
184
152
297
164
243
151
313
215
111
200
456
395
43
202
2...

result:

ok 1000 lines

Test #44:

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

input:

1000 76 1000
1 10 28 32 81 92 99 108 131 136 146 167 177 179 191 199 235 240 243 267 268 273 296 324 343 371 383 388 398 430 442 453 460 472 504 505 539 541 554 575 584 598 618 653 660 670 701 721 724 727 729 731 746 782 799 802 817 826 827 852 859 863 869 875 879 892 899 917 920 930 945 951 954 971...

output:

187
283
321
273
89
396
356
332
454
166
335
331
162
272
432
229
33
360
372
425
113
316
106
202
493
110
191
366
302
412
96
12
236
81
348
430
317
423
240
93
334
471
314
113
308
500
41
218
436
361
21
411
68
342
136
185
398
69
456
475
444
248
289
464
243
450
28
71
261
29
70
331
233
63
120
53
65
428
61
15...

result:

ok 1000 lines

Test #45:

score: 22
Accepted
time: 1ms
memory: 4072kb

input:

1000 86 1000
13 39 42 43 47 52 62 66 84 85 112 121 144 147 158 168 181 193 198 206 214 224 237 245 266 283 289 299 310 318 339 341 352 378 395 403 415 421 423 435 452 454 483 500 505 507 513 515 530 535 544 562 566 589 591 606 617 626 633 643 690 714 722 727 731 738 750 760 770 776 790 822 829 846 8...

output:

450
148
280
215
462
237
200
296
215
105
128
178
262
141
461
27
478
190
36
297
494
183
84
344
133
160
481
476
88
62
279
15
268
485
481
160
152
255
391
78
169
76
135
480
400
294
133
465
349
291
167
448
452
208
496
279
232
417
353
413
209
133
463
299
329
53
253
34
233
37
155
234
299
32
50
474
67
98
489...

result:

ok 1000 lines

Test #46:

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

input:

1000 273 10
0 1 2 5 11 12 16 21 24 25 26 27 32 34 36 38 40 41 42 43 47 50 51 60 62 63 66 68 81 82 90 102 103 104 112 117 120 121 123 127 136 137 140 151 155 157 163 170 173 175 179 182 187 189 190 192 195 197 199 202 206 215 216 217 221 225 230 235 236 240 241 242 246 251 254 258 263 275 286 288 289...

output:

144
473
90
261
241
68
50
218
99
339

result:

ok 10 lines

Test #47:

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

input:

1000 189 100
0 1 8 11 14 17 19 20 39 41 46 48 78 79 83 90 92 93 95 112 125 129 130 133 134 138 142 144 147 152 156 163 166 168 182 184 190 191 194 202 204 207 212 222 231 235 236 238 242 249 253 268 273 289 292 304 305 306 312 314 321 329 338 341 345 346 351 359 364 389 393 396 401 402 409 414 416 4...

output:

182
474
218
35
224
428
57
100
153
450
44
96
27
176
320
14
277
226
303
78
240
277
458
414
5
243
111
130
157
157
347
394
137
413
333
39
92
462
124
390
285
46
481
34
413
67
320
378
76
86
68
135
128
254
254
8
253
360
71
204
108
32
85
13
106
191
122
453
493
378
218
149
387
371
61
266
273
104
25
337
410
4...

result:

ok 100 lines

Test #48:

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

input:

2 1 5
1
0 1
0 3
0 1
0 3
0 1

output:

1
1
1
1
1

result:

ok 5 lines

Test #49:

score: 22
Accepted
time: 1ms
memory: 3868kb

input:

6739019 1 1000
299094
1064733 5993921
4238934 5098210
8941536 5714092
3958289 4920829
683437 3664718
8061642 4798192
8071835 8472811
12554716 7435753
658876 7221970
7519258 11206983
8671149 6851090
6153143 4249882
5883482 8999640
10919729 8527213
5255246 12694196
1632498 13208877
8248451 3927368
876...

output:

1809832
859276
3227444
962540
2981281
3263450
400976
1620057
543640
3051295
1820059
1903261
3116158
2392516
2865804
1901659
4321083
3521494
2619069
4234619
2967785
3506887
2072849
2579162
3231806
3107245
3028746
1844077
4032452
1430885
2395463
4954102
2238219
3027588
3047802
1173294
220128
296029
34...

result:

ok 1000 lines

Test #50:

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

input:

6820828 1 1000
2612881
2635875 5077929
7895911 6434241
5493086 819086
3633802 7472469
5020093 1211954
3830837 10255582
11328967 10277178
9026403 10130766
12196293 5634948
6634282 8574487
7815718 8043067
8471500 12591881
1405078 7195954
4477107 6869056
9479223 7339787
614889 7662213
10287653 310606
3...

output:

2442054
1461670
4674000
2982162
3808139
2039830
1051789
1104363
5784652
1940205
227349
4120381
3445559
2391949
2139436
3769489
3156220
2731725
128619
4357160
1834954
1365306
5280507
2883233
2036766
5049049
3010279
4679914
5016680
307628
5121455
3675317
3617874
5664938
201844
3252610
5530555
1654385
...

result:

ok 1000 lines

Test #51:

score: 22
Accepted
time: 1ms
memory: 4044kb

input:

5728945 290 1000
0 14765 53121 70467 76873 116730 141872 147906 168106 168713 175189 181538 227819 274309 298763 369070 376680 383444 399979 409721 413888 458492 463911 470747 478899 523368 545991 550508 592375 599758 611598 634184 642312 655431 673107 673297 683144 697508 716355 724640 746973 76096...

output:

2524561
943500
1252217
685542
1973734
2168238
2609490
840523
2766536
650473
1447444
185094
356776
2206312
650942
2303304
2111048
836882
203030
1442330
558258
761750
259120
140798
701565
2172980
1042639
2003510
1505988
1775366
1120908
2555493
1416617
1464301
787938
762163
2692878
1434289
2399733
2313...

result:

ok 1000 lines

Test #52:

score: 22
Accepted
time: 1ms
memory: 3804kb

input:

8288739 1000 1000
953 4445 12931 20685 22368 30292 38472 42316 48625 51219 65719 89977 108130 114381 114661 118041 120228 123078 128443 142377 148199 154343 165111 168878 173699 205731 213471 238147 246953 249099 252788 260067 260367 268906 279494 288701 293588 331614 335651 339020 348447 362723 370...

output:

3303928
3612244
3935276
480617
1919849
1350077
2703797
2923025
3662685
4113312
3742307
1536223
2097319
1240486
4066438
753984
2889489
3674918
2528687
793883
499326
3364281
2868438
4074302
3332402
3439356
4055821
1220021
2620345
298784
2582996
3940033
2775697
2600824
1233130
3518090
3971876
1884177
1...

result:

ok 1000 lines

Test #53:

score: 22
Accepted
time: 1ms
memory: 4072kb

input:

5984620 49 1000
0 216708 313436 382686 409312 457323 542483 654231 704106 735180 793266 797608 874897 933204 963645 1219056 1492922 1509307 1892716 2000123 2122154 2245304 2267662 2328939 2400396 2898638 2942717 3416122 3445484 3938174 3962147 4001315 4081489 4247059 4423787 4429232 4646910 4691706 ...

output:

92873
1125684
2888437
2481824
1917294
1517032
260723
1216435
1560047
2152002
1041581
1622762
2265140
488483
2831250
446140
2137463
1266427
201474
1606152
813933
2777662
2644800
1551877
2387573
48869
523893
1289278
1379133
985208
1198681
718015
1273253
1811290
963355
2534839
90948
1458607
2831816
244...

result:

ok 1000 lines

Test #54:

score: 22
Accepted
time: 1ms
memory: 3792kb

input:

9689373 10 1000
135128 440691 884191 3904090 4242800 5937506 6381518 8562794 9206383 9434503
4242468 7286529
7288448 18219569
8139345 8376983
1883053 12903748
13554044 12019604
4952029 19011733
5351612 17834841
2212618 18180437
11957319 10327773
14152901 12840934
10816449 14671495
10613386 18788154
...

output:

3044061
1306945
237638
2710753
1534440
4370332
2793857
3410927
1629546
1311967
3855046
1514606
3371697
1350294
2266288
2453095
3794106
2158763
4219432
4716137
1183091
1274613
3593553
1732636
855820
4598857
4761038
405819
3649419
3850371
2602259
1801430
118191
609713
692560
4511480
1138286
890435
315...

result:

ok 1000 lines

Test #55:

score: 22
Accepted
time: 1ms
memory: 3804kb

input:

3122899 1 1000
2101880
3952570 5545796
1446809 1902349
1785699 3968070
3523668 2124533
3555293 5898573
2790044 109432
6153066 4889258
351840 5939514
3854470 216606
3546960 2420165
166916 144345
1658877 5597955
1539640 2898361
3419130 1258978
876141 2590101
3068376 5431386
1771348 2517384
3075069 527...

output:

1593226
455540
1572891
1399135
2127208
1818616
1263808
658124
2607934
1126795
22571
816180
1358721
2160152
1713960
1173104
746036
2521219
2210895
244797
2590645
1362133
1352503
2456520
21280
2232478
227455
755240
2873504
615935
1061276
1449684
1912577
1645527
900932
1405857
240785
297438
1207913
119...

result:

ok 1000 lines

Test #56:

score: 22
Accepted
time: 1ms
memory: 3800kb

input:

9407802 1 1000
5266183
14473903 7501395
7630243 4421514
6312252 1311571
18516604 12494080
2734742 14191072
8039370 839213
14285544 9102801
12121282 2046822
4342543 5060879
3896417 18635915
7461874 3807343
16461876 6679048
4263551 17826477
2974260 18699296
4819550 12390760
5007920 11512533
4358004 87...

output:

2435295
3208729
5000681
6022524
3014355
7200157
4225060
5772065
718336
4076106
3654531
3200757
4155125
3090568
2729859
3419716
4351302
2445452
2407773
3338279
2199046
4309878
7142856
4513395
4458390
6276749
2351064
2068138
6678604
3796650
5056362
7841455
6729520
3836098
2422036
2379280
3134992
75830...

result:

ok 1000 lines

Test #57:

score: 22
Accepted
time: 1ms
memory: 4080kb

input:

10000000 1000 1000
0 13084 38040 39740 50555 52798 59372 76310 79277 87518 93544 94288 96336 104707 115715 119722 128637 187444 199290 202282 208723 221874 225949 237006 240060 245315 257612 258025 264418 276861 287048 321694 323425 332115 333264 335084 348153 360608 398587 406759 411726 413312 4195...

output:

593547
1453103
3561013
407418
4557674
2589730
4618051
4931587
1627686
4596214
1786988
3971571
4485412
432113
473460
81199
3337995
4510456
3180273
3323803
2905127
2624622
2198419
401793
2086163
645257
4690437
4911362
3619144
333122
452426
1570220
1850501
4289866
1795269
2113229
139353
1903014
3107793...

result:

ok 1000 lines

Test #58:

score: 22
Accepted
time: 1ms
memory: 3792kb

input:

10000000 324 1000
19321 79422 107538 133173 141240 278897 294219 320494 322183 353463 359360 364357 373514 402793 439378 447757 491675 516255 520656 548704 598595 606816 735579 751295 779977 829801 846685 878649 899905 961165 974563 974742 1096864 1152103 1163084 1200595 1215863 1271991 1300918 1327...

output:

517241
1118362
1948356
747859
3338319
1448869
4199020
4950768
276407
3585066
697599
1531957
547402
1207372
600295
4851073
1432158
49087
1488386
4902110
1333306
1614301
92743
1825646
4302458
1777719
673276
584997
1664266
4575355
2655492
442948
883275
3552051
1813255
4977969
3641675
263410
2508104
386...

result:

ok 1000 lines

Test #59:

score: 22
Accepted
time: 1ms
memory: 4068kb

input:

10000000 100 1000
3127 30926 323444 365277 387658 552094 568122 579487 667865 740992 804401 956905 1198507 1338775 1409643 1415788 1568564 1680883 1705192 1744078 1778456 1850075 1889209 1904709 2186228 2198498 2207690 2259690 2313329 2436166 2448465 2584475 2610439 2841387 2854108 2857111 3034438 3...

output:

3126883
2982266
3869230
2463998
265293
3529076
2276364
846470
2037310
2116040
2449341
4683524
3988656
3988764
2496127
15014
1977848
4758938
2959924
1725664
122771
1155082
728193
3865167
4935590
325586
3325337
4537424
149239
3908900
3813461
3102440
2215901
3004204
3570285
1474889
4893544
4301291
1608...

result:

ok 1000 lines

Test #60:

score: 22
Accepted
time: 1ms
memory: 3728kb

input:

10000000 100 1000
77428 121315 143354 270019 308928 767947 918615 955943 986487 1040124 1064491 1306898 1470315 1507639 1543380 1585684 1607960 1716081 1738281 1751933 1796312 2058897 2120976 2290733 2377422 2479939 2490730 2538729 2576207 2647556 2673606 2759030 2927573 3029603 3114407 3138751 3404...

output:

563237
4686990
651988
3989363
4004264
2714870
3078822
3216467
1235105
5943
3935382
3244911
4809595
391161
1416554
2613797
3373054
375790
2237681
152447
3837986
3430389
3784432
3545539
525105
1170660
4458794
3994766
4820051
1381042
4966554
494794
48028
3570699
3503187
3283755
3497621
3481189
4446290
...

result:

ok 1000 lines

Test #61:

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

input:

4 1 5
1
1 4
1 5
1 7
1 2
1 6

output:

2
1
2
1
2

result:

ok 5 lines

Test #62:

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

input:

6 1 3
5
5 7
5 1
5 11

output:

2
3
1

result:

ok 3 lines

Test #63:

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

input:

4 2 4
2 3
0 2
0 3
0 6
0 7

output:

2
2
2
1

result:

ok 4 lines

Test #64:

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

input:

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

output:

1
3
3
3
2

result:

ok 5 lines

Subtask #4:

score: 17
Accepted

Test #65:

score: 17
Accepted
time: 2ms
memory: 3788kb

input:

500000000 1 20000
0
0 912923202
0 578238095
0 603174293
0 263466847
0 418742264
0 93849323
0 192816093
0 175124509
0 192375412
0 65677291
0 314991283
0 421453458
0 235928525
0 645400602
0 496209395
0 214124568
0 36341140
0 648267237
0 683585873
0 965901380
0 711062740
0 65480623
0 822215431
0 895574...

output:

87076798
78238096
103174294
236533154
81257737
93849323
192816093
175124509
192375412
65677291
185008718
78546543
235928525
145400603
3790606
214124568
36341140
148267238
183585874
34098620
211062741
65480623
177784569
104425868
202296888
27011844
110368095
15548777
80603127
221978350
54464776
22526...

result:

ok 20000 lines

Test #66:

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

input:

2 1 5
1
0 1
0 3
0 1
0 3
0 1

output:

1
1
1
1
1

result:

ok 5 lines

Test #67:

score: 17
Accepted
time: 29ms
memory: 6096kb

input:

452192485 349895 20000
296 1342 3174 9723 10231 11071 11073 12454 14464 15195 15986 16293 16436 17761 19072 21484 21514 22590 30086 31442 31932 32264 34891 36941 37695 42179 42271 43072 44723 44975 46962 47305 49785 50453 51914 52209 52563 55100 55776 62107 63783 63926 64086 66853 70536 74228 77405 ...

output:

88507270
110591170
66138325
184775244
24268776
147677597
159938591
32956939
58062696
11169372
103529237
165081518
62743615
37278390
27573785
75588742
7943216
200688797
92190477
59797797
93216550
30739498
25072415
188113405
139720841
20711570
200260796
190665875
182602577
33350968
54295499
216865765
...

result:

ok 20000 lines

Test #68:

score: 17
Accepted
time: 10ms
memory: 4040kb

input:

45335119 80586 20000
977 1342 2185 2770 4973 5456 5647 5653 6300 6391 7142 8309 8363 9179 9387 9561 9943 10018 10570 10737 11286 11978 12822 12891 14314 15183 15564 15626 16234 16236 17541 18047 18090 19541 19656 19855 20520 21686 22813 23228 23621 24769 24924 25178 25340 25530 25765 25799 25930 271...

output:

17178106
11201814
5835126
7554698
391163
9636866
20100150
15623428
11095879
17311919
9077770
8886517
20022004
12024410
15103422
4915638
8969214
3930086
6310185
19502687
9709661
9354258
542822
14024300
15995824
12839624
14317287
13933463
4834618
15634753
8621560
3217844
16278178
10244255
19633970
215...

result:

ok 20000 lines

Test #69:

score: 17
Accepted
time: 4ms
memory: 3848kb

input:

422394922 1 20000
176529031
0 420840861
0 397288212
0 116999960
0 117345372
0 662903064
0 485521665
0 763251353
0 416548187
0 603161003
0 37069928
0 668601562
0 773544058
0 341434607
0 108224142
0 559212430
0 138453586
0 188060797
0 754265397
0 722415638
0 464151092
0 803966481
0 649524432
0 5894125...

output:

354612124
378164773
116999960
117345372
181886780
289931320
81538491
358904798
180766082
37069928
176188282
71245786
341434607
108224142
216240555
138453586
188060797
90524447
122374206
311301893
40823363
195265412
186040478
51896473
28425050
322197230
273381495
54640334
83052771
149886364
206057006...

result:

ok 20000 lines

Test #70:

score: 17
Accepted
time: 2ms
memory: 3848kb

input:

410399021 1 20000
19224735
0 550108879
0 737237816
0 627557254
0 729100274
0 45529683
0 159418051
0 109012310
0 570394056
0 363643444
0 502678664
0 415175728
0 777229153
0 800244897
0 48608189
0 149981572
0 660371156
0 617273104
0 231352961
0 153216578
0 174861827
0 291183564
0 724331784
0 208327380...

output:

139709859
83560226
193240788
91697768
45529683
159418051
109012310
159995036
85205048
92279644
33672764
43568889
20553145
48608189
149981572
160426886
203524938
217495531
153216578
174861827
157664928
96466258
208327380
152053884
172009546
107969827
200881334
91583880
50171020
50777997
206500603
912...

result:

ok 20000 lines

Test #71:

score: 17
Accepted
time: 4ms
memory: 3788kb

input:

488573558 1 20000
262248805
0 116706041
0 308170091
0 467515028
0 825182671
0 389694749
0 868080616
0 180764922
0 714442661
0 751896513
0 293738727
0 431799923
0 230719319
0 67843395
0 379664334
0 849727393
0 718751960
0 243415120
0 317221687
0 186395065
0 840100992
0 469439489
0 303693126
0 1698289...

output:

116706041
272246040
431590977
151964445
353770698
109066500
180764922
262704455
225250603
257814676
395875872
230719319
67843395
343740283
127419723
258395156
243415120
281297636
186395065
137046124
433515438
267769075
169828994
320202339
341049576
406098792
55992634
317054780
288082922
443533312
22...

result:

ok 20000 lines

Test #72:

score: 17
Accepted
time: 4ms
memory: 3756kb

input:

18022733 4 20000
0 1231629 6358450 7129146
0 21500315
0 9646664
0 13484907
0 27615077
0 6043222
0 3494477
0 8251034
0 9497237
0 27022486
0 35666379
0 13062276
0 9467640
0 14645414
0 3070565
0 8945101
0 14426209
0 26472521
0 10184271
0 4731544
0 33820917
0 2426807
0 24274204
0 12830637
0 9702116
0 31...

output:

3477583
8376070
4537827
8430389
6043222
3494477
8251034
8525497
8999754
379087
4960458
8555094
3377320
3070565
8945101
3596525
8449789
7838463
4731544
2224549
2426807
6251472
5192097
8320618
4736421
5856284
3228717
7686232
71567
8994045
4632502
7300494
5934119
797937
1488701
8750658
4903205
8131013
...

result:

ok 20000 lines

Test #73:

score: 17
Accepted
time: 4ms
memory: 3788kb

input:

21669258 3 20000
10466185 15443398 18096283
0 20912209
0 41548125
0 26540371
0 32175211
0 6638270
0 2264620
0 32619220
0 33934823
0 27073440
0 14582373
0 21139586
0 31337861
0 29365924
0 11748379
0 2051941
0 5424141
0 25186955
0 24424526
0 20603308
0 15898685
0 4431518
0 2448176
0 28992587
0 1238188...

output:

6388902
1790391
12017064
10505954
6638270
2264620
10719296
9403693
12550133
7086886
6616279
11263768
13235705
9920880
2051941
5424141
10663648
9901219
6080001
5770574
4431518
2448176
13609042
9287374
6667803
10098373
10729932
10761068
3092978
12146041
13650875
3025378
9087726
8752343
11423539
19732
...

result:

ok 20000 lines

Test #74:

score: 17
Accepted
time: 4ms
memory: 3840kb

input:

168245808 13 20000
1845829 2075013 2374762 5404966 6375972 23361440 43173209 43227246 45867956 57372135 65769193 76580949 107742981
0 216324404
0 165090322
0 21008113
0 298860805
0 282239077
0 13514182
0 261476860
0 45237611
0 299519294
0 94651912
0 39501629
0 190640383
0 5079925
0 193436204
0 19268...

output:

48078597
6847145
21008113
37630811
54252539
13514182
75014756
45237611
36972322
73593897
39501629
22394576
5079925
25190397
24436976
19323767
22018327
42828614
58494098
24314310
34604957
69210763
52178810
77183303
59261866
56498196
47522563
737808
6569606
34262012
5718627
13362665
62785751
22074032
...

result:

ok 20000 lines

Test #75:

score: 17
Accepted
time: 4ms
memory: 3860kb

input:

238685887 16 20000
5637469 6830310 7926411 8090188 11441642 64525553 72752266 78305358 86942837 111751130 129014284 159811564 162268302 208768639 223121953 233651174
0 59056576
0 341503894
0 171425848
0 338290189
0 213380507
0 24586560
0 361362447
0 332118036
0 418805529
0 78316600
0 159115882
0 165...

output:

59056576
102818008
67260040
99604303
25305381
24586560
116009327
93432150
58566245
78316600
79570006
73294673
108959383
19896549
102427667
21064705
107960401
115447595
59481692
14516315
111419561
13730782
82839466
79706033
102590593
59198915
96238872
19031571
92664399
87143971
5770313
89293157
10516...

result:

ok 20000 lines

Test #76:

score: 17
Accepted
time: 5ms
memory: 3788kb

input:

360938266 610 20000
0 14130 337536 428184 1104168 2227473 2339215 2849665 5170064 5407818 6092695 6743127 6852414 7622017 7782245 8422962 8592425 8776521 9543306 10777089 10811655 12347740 12590534 13210339 13918062 14568617 14971754 16139393 16690713 16983998 17062856 19096730 19300954 19749125 203...

output:

34625599
124429384
6777445
131290365
6678470
49871059
66553258
6454284
21708820
121370217
35607366
174105325
104368353
109670206
51634557
139853724
12394875
33323649
99023406
37574454
96151472
19863121
26824834
143187458
30547128
17845129
106682462
137843559
27233605
130623028
178385333
112136570
11...

result:

ok 20000 lines

Test #77:

score: 17
Accepted
time: 5ms
memory: 4088kb

input:

108604505 486 20000
94449 210876 455788 541717 1153027 1229050 1610414 1657465 1693738 1868712 1881661 2125822 2800814 2942636 3462655 3588172 3709372 3924137 4857819 5346806 5605290 5737992 5930167 6132390 6767485 7112529 7214925 7303131 7771784 7806888 8457042 8496210 8550983 8846583 9157613 92247...

output:

19994602
19582340
33392811
47947519
19646112
19570376
17759780
53086145
25452512
40756140
19403267
808168
29959765
13080759
22081568
19875878
31802314
2319739
30127278
35647284
50144206
13015056
28783041
31897467
46955221
3044992
47271890
47443992
53957084
23343244
30598777
6290327
47790488
24625252...

result:

ok 20000 lines

Test #78:

score: 17
Accepted
time: 5ms
memory: 3876kb

input:

997424 6678 20000
298 326 666 909 1285 1667 1929 2051 2100 2166 2393 2608 2658 2791 2913 2996 3343 3684 3822 3844 4174 4218 4227 4258 4347 4420 4461 4523 4530 4567 4814 5167 5172 5364 5422 5676 5714 6230 6258 6283 6563 6593 6632 6900 7150 7384 7549 7613 7670 7831 7929 8034 8143 8227 8466 8505 8561 8...

output:

7894
152778
182362
398394
400052
155776
308051
475146
195001
394204
492613
10999
64748
483108
274134
411240
118725
263606
320983
480238
483787
494473
466180
177597
401000
112381
412155
209204
285908
88514
222256
460305
191812
206626
9430
151404
361467
75211
319139
28255
192531
266308
175599
27262
46...

result:

ok 20000 lines

Test #79:

score: 17
Accepted
time: 19ms
memory: 4840kb

input:

500000000 207709 20000
9326 12223 12891 14526 14877 18866 21777 25567 26647 27226 28788 28796 30797 34711 38701 40071 44735 45027 45440 49153 50417 50956 51697 52642 53994 54597 54978 60377 60950 61544 63813 64349 64400 67464 68875 70315 70631 72527 73374 73474 75154 80860 86615 89800 95932 96716 99...

output:

141059047
24799430
165673057
221028563
90202010
78800260
202425391
180691719
216064738
190998227
113722009
173749467
164351486
61621530
168087854
10617104
153450374
40858670
81552415
194116033
24642786
40694177
100238876
73834846
178368737
182176612
74036527
94581052
147963951
19361768
170086008
145...

result:

ok 20000 lines

Test #80:

score: 17
Accepted
time: 19ms
memory: 4832kb

input:

500000000 199515 20000
5349 10654 11517 12837 22555 28045 28909 29477 31101 33652 38169 40590 41358 43033 44835 46818 47854 49968 50594 51901 55065 56539 57177 57227 60780 61291 62349 66672 68255 70409 74655 74715 77126 77212 77399 78792 92758 95047 98139 98418 98941 104054 104626 106966 107634 1078...

output:

158840478
111800684
154422050
99368611
82546442
242390958
82756055
75196558
31882440
217814546
53984914
98265341
248909277
59254947
151042175
176305173
194992720
168835395
104581721
47332822
26874790
233094575
63375876
62147864
37590136
21679347
22540437
181386273
177852495
156577391
7980206
9365577...

result:

ok 20000 lines

Test #81:

score: 17
Accepted
time: 31ms
memory: 7032kb

input:

500000000 500000 20000
974 1153 1400 1524 1889 3305 3930 4298 5983 6676 9292 11255 11936 14705 14790 16250 16495 16872 16885 17792 22148 24722 24731 25987 26305 26882 27067 27397 30227 30232 30356 31519 32296 33367 33396 33621 33861 34735 35307 37049 39066 39184 40240 41248 41531 41591 42235 42695 4...

output:

23079191
187012274
132205494
229116411
151076375
165755004
39204553
20982642
229263825
70771635
152175215
28926762
57487115
140200855
29591321
67452923
225399805
44481250
25046585
210517715
202249017
238112589
89953980
56003685
127548034
244005958
33625932
221260032
145934614
115586865
127869602
157...

result:

ok 20000 lines

Test #82:

score: 17
Accepted
time: 35ms
memory: 7068kb

input:

500000000 500000 20000
1574 6029 7505 8027 8945 9099 9276 9340 10936 12421 12687 13040 13087 15328 16540 16862 17649 18669 19126 20168 20703 20944 21023 21396 24231 28115 29259 30800 31775 35856 36573 37521 38095 40020 40915 41323 42574 42839 43265 43596 44661 44866 45023 46029 46994 47468 47718 482...

output:

89732945
58822733
142888255
108732111
81496715
7149655
206800443
148508478
153830164
234973063
11005340
184401952
178308607
212233288
42561838
202055375
241824538
34790157
176571342
241278073
84048324
57134273
154436118
75623546
150876551
44176691
161028600
170721190
171949512
88020289
171934914
135...

result:

ok 20000 lines

Test #83:

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

input:

4 2 4
2 3
0 2
0 3
0 6
0 7

output:

2
2
2
1

result:

ok 4 lines

Subtask #5:

score: 27
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Test #84:

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

input:

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

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 20000 lines

Test #85:

score: 27
Accepted
time: 3ms
memory: 3792kb

input:

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

output:

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

result:

ok 20000 lines

Test #86:

score: 27
Accepted
time: 3ms
memory: 3864kb

input:

100 1 20000
99
99 91
99 14
99 35
99 168
99 13
99 177
99 121
99 154
99 18
99 94
99 165
99 107
99 88
99 98
99 126
99 166
99 90
99 198
99 48
99 23
99 46
99 131
99 21
99 123
99 92
99 137
99 128
99 128
99 18
99 80
99 10
99 51
99 186
99 88
99 198
99 142
99 54
99 116
99 2
99 185
99 169
99 56
99 135
99 148
...

output:

8
16
37
32
15
23
22
46
20
5
35
8
11
1
27
34
9
2
50
25
48
32
23
24
7
38
29
29
20
19
12
48
14
11
2
43
45
17
4
15
31
43
36
49
39
40
22
17
25
32
39
24
3
9
24
7
10
24
37
4
28
30
37
5
18
19
44
9
49
42
47
10
8
1
40
45
44
26
49
27
46
17
8
25
20
15
11
35
18
41
12
34
37
43
14
44
42
26
40
41
26
45
5
4
3
41
44
...

result:

ok 20000 lines

Test #87:

score: 27
Accepted
time: 0ms
memory: 3756kb

input:

1000 1 1
694
694 891

output:

197

result:

ok single line: '197'

Test #88:

score: 27
Accepted
time: 4ms
memory: 3728kb

input:

100000 1 20000
93018
93018 92828
93018 124203
93018 180530
93018 117244
93018 32089
93018 47616
93018 56972
93018 2771
93018 166821
93018 82000
93018 53651
93018 152580
93018 146287
93018 161214
93018 124947
93018 67461
93018 29407
93018 174059
93018 108598
93018 36288
93018 130879
93018 197004
9301...

output:

190
31185
12489
24226
39072
45402
36046
9754
26198
11018
39367
40439
46732
31805
31929
25557
36390
18960
15580
43271
37861
3987
1682
16615
25363
11592
25989
47041
2369
35703
6132
26409
5626
9187
3259
18048
28989
39551
33325
5540
29180
15338
32087
9180
25474
45192
49252
28286
46436
10665
7270
32861
6...

result:

ok 20000 lines

Test #89:

score: 27
Accepted
time: 4ms
memory: 3728kb

input:

500000000 1 20000
0
0 912923202
0 578238095
0 603174293
0 263466847
0 418742264
0 93849323
0 192816093
0 175124509
0 192375412
0 65677291
0 314991283
0 421453458
0 235928525
0 645400602
0 496209395
0 214124568
0 36341140
0 648267237
0 683585873
0 965901380
0 711062740
0 65480623
0 822215431
0 895574...

output:

87076798
78238096
103174294
236533154
81257737
93849323
192816093
175124509
192375412
65677291
185008718
78546543
235928525
145400603
3790606
214124568
36341140
148267238
183585874
34098620
211062741
65480623
177784569
104425868
202296888
27011844
110368095
15548777
80603127
221978350
54464776
22526...

result:

ok 20000 lines

Test #90:

score: 27
Accepted
time: 5ms
memory: 4044kb

input:

500000000 1 20000
52007973
52007973 87413823
52007973 247004975
52007973 884551041
52007973 161702009
52007973 892694089
52007973 632824937
52007973 177843603
52007973 313022454
52007973 625221799
52007973 634707855
52007973 589915468
52007973 702833391
52007973 957683052
52007973 84410910
52007973 ...

output:

35405850
194997002
167456932
109694036
159313884
80816965
125835630
238985520
73213827
82699883
37907496
150825419
94324921
32402937
4769622
165378271
202601759
25897974
101247495
232601224
129969454
134165089
222107881
154018264
83688917
193733976
2310458
108381970
209429847
245322356
127109145
248...

result:

ok 20000 lines

Test #91:

score: 27
Accepted
time: 5ms
memory: 3796kb

input:

500000000 1 20000
268203494
268203494 628297992
268203494 360304257
268203494 965307290
268203494 478270227
268203494 184713809
268203494 602949889
268203494 856591419
268203494 451463558
268203494 566210210
268203494 620395684
268203494 397827048
268203494 982753046
268203494 771712581
268203494 70...

output:

139905503
92100763
197103797
210066733
83489685
165253606
88387926
183260064
201993285
147807811
129623554
214549553
3509088
61014113
208655602
165098644
190758000
97786170
132226477
227745765
132020400
2640713
223740448
127711827
226503809
205321315
201825223
66033023
25751046
88553
171160149
24636...

result:

ok 20000 lines

Test #92:

score: 27
Accepted
time: 5ms
memory: 3800kb

input:

500000000 1 20000
188717824
188717824 296338508
188717824 612677479
188717824 215911204
188717824 276694321
188717824 810184200
188717824 65884877
188717824 77273999
188717824 309536692
188717824 930212412
188717824 50660607
188717824 797560592
188717824 264531784
188717824 46380654
188717824 628913...

output:

107620684
76040346
27193380
87976497
121466377
122832947
111443825
120818868
241494589
138057217
108842769
75813960
142337170
59804159
206795473
52702017
79476529
215584824
200251320
227956419
190945748
104091573
144616854
145346962
17495834
67689077
54486995
119848287
35971689
224697124
114644802
2...

result:

ok 20000 lines

Test #93:

score: 27
Accepted
time: 5ms
memory: 3788kb

input:

500000000 1 20000
440287253
440287253 865756918
440287253 346988225
440287253 713601177
440287253 371434297
440287253 887727641
440287253 953472596
440287253 389562860
440287253 624961030
440287253 298227534
440287253 813860613
440287253 415399403
440287253 941974177
440287253 321514752
440287253 30...

output:

74530336
93299028
226686077
68852956
52559613
13185344
50724393
184673777
142059719
126426641
24887850
1686925
118772501
135455899
82821314
145582027
202537317
181960515
122917192
188248617
173783328
114030885
10389717
88246345
49446258
93132168
224691138
2666784
202434840
12640616
189236830
1234962...

result:

ok 20000 lines

Test #94:

score: 27
Accepted
time: 0ms
memory: 3860kb

input:

326 1 1000
166
173 18
580 117
400 211
298 130
237 56
537 628
276 277
555 630
8 488
616 592
98 358
541 159
456 360
495 276
371 203
551 402
376 539
524 209
368 263
493 625
87 206
468 369
209 146
358 540
127 76
331 15
200 3
623 453
277 410
63 83
128 628
502 476
243 551
316 193
116 257
421 594
158 494
2...

output:

155
138
138
168
181
91
1
75
163
24
203
57
96
114
159
149
163
76
105
132
119
99
63
182
51
313
197
170
133
20
152
26
137
123
141
173
11
128
192
47
156
40
100
202
32
46
6
141
120
89
168
117
213
53
24
147
113
156
26
42
117
110
195
113
77
154
135
200
316
192
233
87
153
163
159
13
160
162
99
111
157
62
11...

result:

ok 1000 lines

Test #95:

score: 27
Accepted
time: 0ms
memory: 3788kb

input:

397 1 1000
103
256 424
792 670
620 683
228 717
248 713
361 163
28 41
149 102
692 531
493 173
353 70
236 788
243 116
771 236
228 528
780 604
504 656
497 487
569 297
134 339
162 42
569 644
443 192
494 192
639 267
329 528
685 617
783 193
358 712
316 636
539 383
756 772
385 46
293 401
548 565
122 712
61...

output:

168
122
63
305
329
198
13
47
161
78
181
242
127
259
154
176
152
10
264
193
120
75
147
96
304
199
68
204
328
320
156
16
173
108
17
204
155
189
97
166
19
47
282
35
196
211
223
242
292
183
290
114
139
194
169
22
112
11
41
132
143
72
130
31
289
202
383
209
257
261
16
116
69
131
102
109
267
13
77
54
246
...

result:

ok 1000 lines

Test #96:

score: 27
Accepted
time: 0ms
memory: 3816kb

input:

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

output:

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

result:

ok 1000 lines

Test #97:

score: 27
Accepted
time: 1ms
memory: 3752kb

input:

81 75 1000
0 1 2 3 4 5 6 7 8 10 11 12 14 15 16 17 18 19 21 22 24 25 26 27 28 29 30 31 32 33 34 35 36 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
74 101
35 101
8 150
74 133
11 68
17 70
132 29
46 53
1 59
59 132
71 37
67 ...

output:

27
16
20
23
25
29
23
7
24
9
34
2
28
14
35
25
31
7
7
30
31
7
27
8
31
24
6
36
38
27
4
30
10
24
28
18
19
18
33
7
41
33
33
23
1
35
19
23
28
32
32
5
16
40
18
10
7
31
12
15
17
41
3
6
4
32
39
22
16
21
10
16
8
30
16
15
32
39
11
13
15
1
28
6
16
3
8
17
19
19
2
24
9
25
3
5
4
7
37
33
10
31
21
37
39
23
19
14
11
...

result:

ok 1000 lines

Test #98:

score: 27
Accepted
time: 1ms
memory: 4068kb

input:

109 12 1000
0 35 39 43 63 69 75 85 86 95 100 106
164 44
174 160
139 180
112 143
164 88
216 102
159 89
133 2
214 107
119 140
116 183
73 15
135 189
180 108
216 11
192 118
32 84
70 31
81 75
135 156
80 16
199 80
120 90
90 183
145 29
117 211
16 149
200 34
94 134
69 44
188 70
205 104
123 84
180 212
159 83...

output:

14
14
41
31
34
6
40
27
3
21
43
52
54
38
13
36
52
39
6
21
46
11
30
17
8
16
25
52
40
25
10
9
39
32
34
52
46
35
15
8
54
32
12
41
22
40
16
40
37
17
42
39
27
51
22
42
24
6
5
44
8
18
31
37
38
24
37
49
35
10
12
18
16
4
7
32
13
11
28
50
47
3
24
14
38
11
54
19
17
36
39
34
26
16
26
15
51
44
8
25
21
47
9
20
44...

result:

ok 1000 lines

Test #99:

score: 27
Accepted
time: 1ms
memory: 3784kb

input:

299 207 1000
2 5 6 7 8 11 13 15 16 17 20 23 24 26 28 31 32 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 53 54 55 56 57 58 59 60 61 64 65 66 67 68 70 74 75 77 78 81 83 84 85 86 88 89 90 91 92 93 95 96 97 98 99 101 102 103 104 105 106 107 109 111 112 114 115 116 117 119 121 122 123 124 125 127 1...

output:

8
120
22
4
82
136
2
17
112
26
56
150
61
37
69
21
57
25
39
67
93
115
104
138
140
90
122
41
50
40
107
15
9
98
13
35
99
99
106
10
59
38
57
122
40
18
23
35
109
57
47
2
37
14
107
8
101
58
131
71
12
133
6
148
88
34
106
91
101
52
62
95
51
67
45
2
117
118
112
4
47
44
10
119
17
27
110
62
55
38
144
29
111
92
...

result:

ok 1000 lines

Test #100:

score: 27
Accepted
time: 1ms
memory: 3840kb

input:

1000 43 1000
25 32 44 93 101 141 160 171 185 188 212 227 236 253 259 274 351 355 440 446 450 466 573 577 586 612 644 645 647 652 657 684 717 756 790 801 838 863 939 948 957 979 989
1065 974
1468 1131
674 913
1101 1445
1636 1608
749 433
74 1246
786 450
189 296
1655 1531
1668 839
222 1270
201 198
1156...

output:

91
337
239
344
28
316
173
336
107
124
172
49
3
66
266
294
402
122
24
480
312
91
138
142
324
247
111
429
278
103
170
10
253
391
169
302
322
231
441
488
279
129
412
484
109
383
15
125
151
336
87
206
113
114
205
437
169
330
75
485
45
322
146
306
34
360
273
16
254
385
50
176
173
469
439
196
447
184
430
...

result:

ok 1000 lines

Test #101:

score: 27
Accepted
time: 1ms
memory: 3784kb

input:

1000 816 1000
0 1 2 3 4 5 6 7 9 10 12 13 14 15 16 18 19 20 21 23 24 25 26 27 28 29 30 32 33 35 36 37 38 39 40 41 42 43 46 47 50 51 52 54 55 56 57 58 59 61 62 63 64 65 66 67 69 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 94 95 97 98 99 100 101 102 103 104 105 106 107 108 109 110...

output:

490
21
108
53
395
499
379
261
459
198
294
301
88
490
76
143
473
78
472
337
450
342
283
270
210
106
193
224
87
45
104
358
90
480
259
300
271
229
370
364
441
41
243
483
482
261
125
250
148
332
232
19
404
130
383
106
57
338
117
41
111
402
127
134
219
432
57
451
438
383
341
80
50
133
356
456
384
40
93
3...

result:

ok 1000 lines

Test #102:

score: 27
Accepted
time: 1ms
memory: 4044kb

input:

1000 6 1000
0 203 277 537 759 922
1160 366
86 1181
418 53
1094 1509
725 1777
1162 1629
1551 1800
468 239
1928 1235
1783 267
412 232
1700 554
1254 126
408 809
912 612
707 362
1076 648
335 700
22 1030
1463 1333
1009 391
1656 1119
1016 1476
589 1107
1060 1098
1273 236
47 254
794 11
819 480
372 523
1250...

output:

207
140
365
415
53
467
249
229
308
484
180
181
129
401
300
345
428
365
53
130
383
464
460
483
38
46
207
218
339
151
202
135
95
385
421
247
307
171
367
443
408
474
205
49
456
22
437
268
256
387
72
483
248
473
28
497
492
432
450
228
436
479
469
473
431
342
59
296
227
475
26
78
78
297
45
447
314
137
52...

result:

ok 1000 lines

Test #103:

score: 27
Accepted
time: 0ms
memory: 3740kb

input:

1000 6 1000
104 432 500 801 975 998
798 1474
376 497
1158 140
9 1761
512 1397
1649 1771
1128 1575
1604 1628
1681 144
1915 1174
933 1726
416 389
699 1538
1830 1755
237 302
374 461
27 1678
75 1761
213 886
1860 106
1300 361
870 391
1752 1286
1593 1013
617 257
343 345
975 106
1472 1708
1646 1682
1204 83...

output:

325
121
91
248
116
122
447
24
463
260
208
27
238
75
65
87
349
314
328
246
204
479
466
421
360
2
132
236
36
370
149
86
205
343
67
321
261
388
60
220
157
159
456
424
458
273
91
181
375
316
222
373
135
210
469
240
8
407
190
49
245
369
277
143
321
184
152
297
164
243
151
313
215
111
200
456
395
43
202
2...

result:

ok 1000 lines

Test #104:

score: 27
Accepted
time: 1ms
memory: 3784kb

input:

1000 76 1000
1 10 28 32 81 92 99 108 131 136 146 167 177 179 191 199 235 240 243 267 268 273 296 324 343 371 383 388 398 430 442 453 460 472 504 505 539 541 554 575 584 598 618 653 660 670 701 721 724 727 729 731 746 782 799 802 817 826 827 852 859 863 869 875 879 892 899 917 920 930 945 951 954 971...

output:

187
283
321
273
89
396
356
332
454
166
335
331
162
272
432
229
33
360
372
425
113
316
106
202
493
110
191
366
302
412
96
12
236
81
348
430
317
423
240
93
334
471
314
113
308
500
41
218
436
361
21
411
68
342
136
185
398
69
456
475
444
248
289
464
243
450
28
71
261
29
70
331
233
63
120
53
65
428
61
15...

result:

ok 1000 lines

Test #105:

score: 27
Accepted
time: 1ms
memory: 3780kb

input:

1000 86 1000
13 39 42 43 47 52 62 66 84 85 112 121 144 147 158 168 181 193 198 206 214 224 237 245 266 283 289 299 310 318 339 341 352 378 395 403 415 421 423 435 452 454 483 500 505 507 513 515 530 535 544 562 566 589 591 606 617 626 633 643 690 714 722 727 731 738 750 760 770 776 790 822 829 846 8...

output:

450
148
280
215
462
237
200
296
215
105
128
178
262
141
461
27
478
190
36
297
494
183
84
344
133
160
481
476
88
62
279
15
268
485
481
160
152
255
391
78
169
76
135
480
400
294
133
465
349
291
167
448
452
208
496
279
232
417
353
413
209
133
463
299
329
53
253
34
233
37
155
234
299
32
50
474
67
98
489...

result:

ok 1000 lines

Test #106:

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

input:

1000 273 10
0 1 2 5 11 12 16 21 24 25 26 27 32 34 36 38 40 41 42 43 47 50 51 60 62 63 66 68 81 82 90 102 103 104 112 117 120 121 123 127 136 137 140 151 155 157 163 170 173 175 179 182 187 189 190 192 195 197 199 202 206 215 216 217 221 225 230 235 236 240 241 242 246 251 254 258 263 275 286 288 289...

output:

144
473
90
261
241
68
50
218
99
339

result:

ok 10 lines

Test #107:

score: 27
Accepted
time: 0ms
memory: 3760kb

input:

1000 189 100
0 1 8 11 14 17 19 20 39 41 46 48 78 79 83 90 92 93 95 112 125 129 130 133 134 138 142 144 147 152 156 163 166 168 182 184 190 191 194 202 204 207 212 222 231 235 236 238 242 249 253 268 273 289 292 304 305 306 312 314 321 329 338 341 345 346 351 359 364 389 393 396 401 402 409 414 416 4...

output:

182
474
218
35
224
428
57
100
153
450
44
96
27
176
320
14
277
226
303
78
240
277
458
414
5
243
111
130
157
157
347
394
137
413
333
39
92
462
124
390
285
46
481
34
413
67
320
378
76
86
68
135
128
254
254
8
253
360
71
204
108
32
85
13
106
191
122
453
493
378
218
149
387
371
61
266
273
104
25
337
410
4...

result:

ok 100 lines

Test #108:

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

input:

2 1 5
1
0 1
0 3
0 1
0 3
0 1

output:

1
1
1
1
1

result:

ok 5 lines

Test #109:

score: 27
Accepted
time: 0ms
memory: 3756kb

input:

6739019 1 1000
299094
1064733 5993921
4238934 5098210
8941536 5714092
3958289 4920829
683437 3664718
8061642 4798192
8071835 8472811
12554716 7435753
658876 7221970
7519258 11206983
8671149 6851090
6153143 4249882
5883482 8999640
10919729 8527213
5255246 12694196
1632498 13208877
8248451 3927368
876...

output:

1809832
859276
3227444
962540
2981281
3263450
400976
1620057
543640
3051295
1820059
1903261
3116158
2392516
2865804
1901659
4321083
3521494
2619069
4234619
2967785
3506887
2072849
2579162
3231806
3107245
3028746
1844077
4032452
1430885
2395463
4954102
2238219
3027588
3047802
1173294
220128
296029
34...

result:

ok 1000 lines

Test #110:

score: 27
Accepted
time: 1ms
memory: 3800kb

input:

6820828 1 1000
2612881
2635875 5077929
7895911 6434241
5493086 819086
3633802 7472469
5020093 1211954
3830837 10255582
11328967 10277178
9026403 10130766
12196293 5634948
6634282 8574487
7815718 8043067
8471500 12591881
1405078 7195954
4477107 6869056
9479223 7339787
614889 7662213
10287653 310606
3...

output:

2442054
1461670
4674000
2982162
3808139
2039830
1051789
1104363
5784652
1940205
227349
4120381
3445559
2391949
2139436
3769489
3156220
2731725
128619
4357160
1834954
1365306
5280507
2883233
2036766
5049049
3010279
4679914
5016680
307628
5121455
3675317
3617874
5664938
201844
3252610
5530555
1654385
...

result:

ok 1000 lines

Test #111:

score: 27
Accepted
time: 1ms
memory: 4072kb

input:

5728945 290 1000
0 14765 53121 70467 76873 116730 141872 147906 168106 168713 175189 181538 227819 274309 298763 369070 376680 383444 399979 409721 413888 458492 463911 470747 478899 523368 545991 550508 592375 599758 611598 634184 642312 655431 673107 673297 683144 697508 716355 724640 746973 76096...

output:

2524561
943500
1252217
685542
1973734
2168238
2609490
840523
2766536
650473
1447444
185094
356776
2206312
650942
2303304
2111048
836882
203030
1442330
558258
761750
259120
140798
701565
2172980
1042639
2003510
1505988
1775366
1120908
2555493
1416617
1464301
787938
762163
2692878
1434289
2399733
2313...

result:

ok 1000 lines

Test #112:

score: 27
Accepted
time: 1ms
memory: 3832kb

input:

8288739 1000 1000
953 4445 12931 20685 22368 30292 38472 42316 48625 51219 65719 89977 108130 114381 114661 118041 120228 123078 128443 142377 148199 154343 165111 168878 173699 205731 213471 238147 246953 249099 252788 260067 260367 268906 279494 288701 293588 331614 335651 339020 348447 362723 370...

output:

3303928
3612244
3935276
480617
1919849
1350077
2703797
2923025
3662685
4113312
3742307
1536223
2097319
1240486
4066438
753984
2889489
3674918
2528687
793883
499326
3364281
2868438
4074302
3332402
3439356
4055821
1220021
2620345
298784
2582996
3940033
2775697
2600824
1233130
3518090
3971876
1884177
1...

result:

ok 1000 lines

Test #113:

score: 27
Accepted
time: 1ms
memory: 3780kb

input:

5984620 49 1000
0 216708 313436 382686 409312 457323 542483 654231 704106 735180 793266 797608 874897 933204 963645 1219056 1492922 1509307 1892716 2000123 2122154 2245304 2267662 2328939 2400396 2898638 2942717 3416122 3445484 3938174 3962147 4001315 4081489 4247059 4423787 4429232 4646910 4691706 ...

output:

92873
1125684
2888437
2481824
1917294
1517032
260723
1216435
1560047
2152002
1041581
1622762
2265140
488483
2831250
446140
2137463
1266427
201474
1606152
813933
2777662
2644800
1551877
2387573
48869
523893
1289278
1379133
985208
1198681
718015
1273253
1811290
963355
2534839
90948
1458607
2831816
244...

result:

ok 1000 lines

Test #114:

score: 27
Accepted
time: 1ms
memory: 4092kb

input:

9689373 10 1000
135128 440691 884191 3904090 4242800 5937506 6381518 8562794 9206383 9434503
4242468 7286529
7288448 18219569
8139345 8376983
1883053 12903748
13554044 12019604
4952029 19011733
5351612 17834841
2212618 18180437
11957319 10327773
14152901 12840934
10816449 14671495
10613386 18788154
...

output:

3044061
1306945
237638
2710753
1534440
4370332
2793857
3410927
1629546
1311967
3855046
1514606
3371697
1350294
2266288
2453095
3794106
2158763
4219432
4716137
1183091
1274613
3593553
1732636
855820
4598857
4761038
405819
3649419
3850371
2602259
1801430
118191
609713
692560
4511480
1138286
890435
315...

result:

ok 1000 lines

Test #115:

score: 27
Accepted
time: 1ms
memory: 3760kb

input:

3122899 1 1000
2101880
3952570 5545796
1446809 1902349
1785699 3968070
3523668 2124533
3555293 5898573
2790044 109432
6153066 4889258
351840 5939514
3854470 216606
3546960 2420165
166916 144345
1658877 5597955
1539640 2898361
3419130 1258978
876141 2590101
3068376 5431386
1771348 2517384
3075069 527...

output:

1593226
455540
1572891
1399135
2127208
1818616
1263808
658124
2607934
1126795
22571
816180
1358721
2160152
1713960
1173104
746036
2521219
2210895
244797
2590645
1362133
1352503
2456520
21280
2232478
227455
755240
2873504
615935
1061276
1449684
1912577
1645527
900932
1405857
240785
297438
1207913
119...

result:

ok 1000 lines

Test #116:

score: 27
Accepted
time: 1ms
memory: 3796kb

input:

9407802 1 1000
5266183
14473903 7501395
7630243 4421514
6312252 1311571
18516604 12494080
2734742 14191072
8039370 839213
14285544 9102801
12121282 2046822
4342543 5060879
3896417 18635915
7461874 3807343
16461876 6679048
4263551 17826477
2974260 18699296
4819550 12390760
5007920 11512533
4358004 87...

output:

2435295
3208729
5000681
6022524
3014355
7200157
4225060
5772065
718336
4076106
3654531
3200757
4155125
3090568
2729859
3419716
4351302
2445452
2407773
3338279
2199046
4309878
7142856
4513395
4458390
6276749
2351064
2068138
6678604
3796650
5056362
7841455
6729520
3836098
2422036
2379280
3134992
75830...

result:

ok 1000 lines

Test #117:

score: 27
Accepted
time: 0ms
memory: 3796kb

input:

10000000 1000 1000
0 13084 38040 39740 50555 52798 59372 76310 79277 87518 93544 94288 96336 104707 115715 119722 128637 187444 199290 202282 208723 221874 225949 237006 240060 245315 257612 258025 264418 276861 287048 321694 323425 332115 333264 335084 348153 360608 398587 406759 411726 413312 4195...

output:

593547
1453103
3561013
407418
4557674
2589730
4618051
4931587
1627686
4596214
1786988
3971571
4485412
432113
473460
81199
3337995
4510456
3180273
3323803
2905127
2624622
2198419
401793
2086163
645257
4690437
4911362
3619144
333122
452426
1570220
1850501
4289866
1795269
2113229
139353
1903014
3107793...

result:

ok 1000 lines

Test #118:

score: 27
Accepted
time: 1ms
memory: 3788kb

input:

10000000 324 1000
19321 79422 107538 133173 141240 278897 294219 320494 322183 353463 359360 364357 373514 402793 439378 447757 491675 516255 520656 548704 598595 606816 735579 751295 779977 829801 846685 878649 899905 961165 974563 974742 1096864 1152103 1163084 1200595 1215863 1271991 1300918 1327...

output:

517241
1118362
1948356
747859
3338319
1448869
4199020
4950768
276407
3585066
697599
1531957
547402
1207372
600295
4851073
1432158
49087
1488386
4902110
1333306
1614301
92743
1825646
4302458
1777719
673276
584997
1664266
4575355
2655492
442948
883275
3552051
1813255
4977969
3641675
263410
2508104
386...

result:

ok 1000 lines

Test #119:

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

input:

10000000 100 1000
3127 30926 323444 365277 387658 552094 568122 579487 667865 740992 804401 956905 1198507 1338775 1409643 1415788 1568564 1680883 1705192 1744078 1778456 1850075 1889209 1904709 2186228 2198498 2207690 2259690 2313329 2436166 2448465 2584475 2610439 2841387 2854108 2857111 3034438 3...

output:

3126883
2982266
3869230
2463998
265293
3529076
2276364
846470
2037310
2116040
2449341
4683524
3988656
3988764
2496127
15014
1977848
4758938
2959924
1725664
122771
1155082
728193
3865167
4935590
325586
3325337
4537424
149239
3908900
3813461
3102440
2215901
3004204
3570285
1474889
4893544
4301291
1608...

result:

ok 1000 lines

Test #120:

score: 27
Accepted
time: 1ms
memory: 3792kb

input:

10000000 100 1000
77428 121315 143354 270019 308928 767947 918615 955943 986487 1040124 1064491 1306898 1470315 1507639 1543380 1585684 1607960 1716081 1738281 1751933 1796312 2058897 2120976 2290733 2377422 2479939 2490730 2538729 2576207 2647556 2673606 2759030 2927573 3029603 3114407 3138751 3404...

output:

563237
4686990
651988
3989363
4004264
2714870
3078822
3216467
1235105
5943
3935382
3244911
4809595
391161
1416554
2613797
3373054
375790
2237681
152447
3837986
3430389
3784432
3545539
525105
1170660
4458794
3994766
4820051
1381042
4966554
494794
48028
3570699
3503187
3283755
3497621
3481189
4446290
...

result:

ok 1000 lines

Test #121:

score: 27
Accepted
time: 29ms
memory: 6128kb

input:

452192485 349895 20000
296 1342 3174 9723 10231 11071 11073 12454 14464 15195 15986 16293 16436 17761 19072 21484 21514 22590 30086 31442 31932 32264 34891 36941 37695 42179 42271 43072 44723 44975 46962 47305 49785 50453 51914 52209 52563 55100 55776 62107 63783 63926 64086 66853 70536 74228 77405 ...

output:

88507270
110591170
66138325
184775244
24268776
147677597
159938591
32956939
58062696
11169372
103529237
165081518
62743615
37278390
27573785
75588742
7943216
200688797
92190477
59797797
93216550
30739498
25072415
188113405
139720841
20711570
200260796
190665875
182602577
33350968
54295499
216865765
...

result:

ok 20000 lines

Test #122:

score: 27
Accepted
time: 7ms
memory: 3964kb

input:

45335119 80586 20000
977 1342 2185 2770 4973 5456 5647 5653 6300 6391 7142 8309 8363 9179 9387 9561 9943 10018 10570 10737 11286 11978 12822 12891 14314 15183 15564 15626 16234 16236 17541 18047 18090 19541 19656 19855 20520 21686 22813 23228 23621 24769 24924 25178 25340 25530 25765 25799 25930 271...

output:

17178106
11201814
5835126
7554698
391163
9636866
20100150
15623428
11095879
17311919
9077770
8886517
20022004
12024410
15103422
4915638
8969214
3930086
6310185
19502687
9709661
9354258
542822
14024300
15995824
12839624
14317287
13933463
4834618
15634753
8621560
3217844
16278178
10244255
19633970
215...

result:

ok 20000 lines

Test #123:

score: 27
Accepted
time: 4ms
memory: 3816kb

input:

422394922 1 20000
176529031
0 420840861
0 397288212
0 116999960
0 117345372
0 662903064
0 485521665
0 763251353
0 416548187
0 603161003
0 37069928
0 668601562
0 773544058
0 341434607
0 108224142
0 559212430
0 138453586
0 188060797
0 754265397
0 722415638
0 464151092
0 803966481
0 649524432
0 5894125...

output:

354612124
378164773
116999960
117345372
181886780
289931320
81538491
358904798
180766082
37069928
176188282
71245786
341434607
108224142
216240555
138453586
188060797
90524447
122374206
311301893
40823363
195265412
186040478
51896473
28425050
322197230
273381495
54640334
83052771
149886364
206057006...

result:

ok 20000 lines

Test #124:

score: 27
Accepted
time: 4ms
memory: 3780kb

input:

410399021 1 20000
19224735
0 550108879
0 737237816
0 627557254
0 729100274
0 45529683
0 159418051
0 109012310
0 570394056
0 363643444
0 502678664
0 415175728
0 777229153
0 800244897
0 48608189
0 149981572
0 660371156
0 617273104
0 231352961
0 153216578
0 174861827
0 291183564
0 724331784
0 208327380...

output:

139709859
83560226
193240788
91697768
45529683
159418051
109012310
159995036
85205048
92279644
33672764
43568889
20553145
48608189
149981572
160426886
203524938
217495531
153216578
174861827
157664928
96466258
208327380
152053884
172009546
107969827
200881334
91583880
50171020
50777997
206500603
912...

result:

ok 20000 lines

Test #125:

score: 27
Accepted
time: 4ms
memory: 3788kb

input:

488573558 1 20000
262248805
0 116706041
0 308170091
0 467515028
0 825182671
0 389694749
0 868080616
0 180764922
0 714442661
0 751896513
0 293738727
0 431799923
0 230719319
0 67843395
0 379664334
0 849727393
0 718751960
0 243415120
0 317221687
0 186395065
0 840100992
0 469439489
0 303693126
0 1698289...

output:

116706041
272246040
431590977
151964445
353770698
109066500
180764922
262704455
225250603
257814676
395875872
230719319
67843395
343740283
127419723
258395156
243415120
281297636
186395065
137046124
433515438
267769075
169828994
320202339
341049576
406098792
55992634
317054780
288082922
443533312
22...

result:

ok 20000 lines

Test #126:

score: 27
Accepted
time: 4ms
memory: 3784kb

input:

18022733 4 20000
0 1231629 6358450 7129146
0 21500315
0 9646664
0 13484907
0 27615077
0 6043222
0 3494477
0 8251034
0 9497237
0 27022486
0 35666379
0 13062276
0 9467640
0 14645414
0 3070565
0 8945101
0 14426209
0 26472521
0 10184271
0 4731544
0 33820917
0 2426807
0 24274204
0 12830637
0 9702116
0 31...

output:

3477583
8376070
4537827
8430389
6043222
3494477
8251034
8525497
8999754
379087
4960458
8555094
3377320
3070565
8945101
3596525
8449789
7838463
4731544
2224549
2426807
6251472
5192097
8320618
4736421
5856284
3228717
7686232
71567
8994045
4632502
7300494
5934119
797937
1488701
8750658
4903205
8131013
...

result:

ok 20000 lines

Test #127:

score: 27
Accepted
time: 4ms
memory: 3796kb

input:

21669258 3 20000
10466185 15443398 18096283
0 20912209
0 41548125
0 26540371
0 32175211
0 6638270
0 2264620
0 32619220
0 33934823
0 27073440
0 14582373
0 21139586
0 31337861
0 29365924
0 11748379
0 2051941
0 5424141
0 25186955
0 24424526
0 20603308
0 15898685
0 4431518
0 2448176
0 28992587
0 1238188...

output:

6388902
1790391
12017064
10505954
6638270
2264620
10719296
9403693
12550133
7086886
6616279
11263768
13235705
9920880
2051941
5424141
10663648
9901219
6080001
5770574
4431518
2448176
13609042
9287374
6667803
10098373
10729932
10761068
3092978
12146041
13650875
3025378
9087726
8752343
11423539
19732
...

result:

ok 20000 lines

Test #128:

score: 27
Accepted
time: 4ms
memory: 3816kb

input:

168245808 13 20000
1845829 2075013 2374762 5404966 6375972 23361440 43173209 43227246 45867956 57372135 65769193 76580949 107742981
0 216324404
0 165090322
0 21008113
0 298860805
0 282239077
0 13514182
0 261476860
0 45237611
0 299519294
0 94651912
0 39501629
0 190640383
0 5079925
0 193436204
0 19268...

output:

48078597
6847145
21008113
37630811
54252539
13514182
75014756
45237611
36972322
73593897
39501629
22394576
5079925
25190397
24436976
19323767
22018327
42828614
58494098
24314310
34604957
69210763
52178810
77183303
59261866
56498196
47522563
737808
6569606
34262012
5718627
13362665
62785751
22074032
...

result:

ok 20000 lines

Test #129:

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

input:

238685887 16 20000
5637469 6830310 7926411 8090188 11441642 64525553 72752266 78305358 86942837 111751130 129014284 159811564 162268302 208768639 223121953 233651174
0 59056576
0 341503894
0 171425848
0 338290189
0 213380507
0 24586560
0 361362447
0 332118036
0 418805529
0 78316600
0 159115882
0 165...

output:

59056576
102818008
67260040
99604303
25305381
24586560
116009327
93432150
58566245
78316600
79570006
73294673
108959383
19896549
102427667
21064705
107960401
115447595
59481692
14516315
111419561
13730782
82839466
79706033
102590593
59198915
96238872
19031571
92664399
87143971
5770313
89293157
10516...

result:

ok 20000 lines

Test #130:

score: 27
Accepted
time: 5ms
memory: 4072kb

input:

360938266 610 20000
0 14130 337536 428184 1104168 2227473 2339215 2849665 5170064 5407818 6092695 6743127 6852414 7622017 7782245 8422962 8592425 8776521 9543306 10777089 10811655 12347740 12590534 13210339 13918062 14568617 14971754 16139393 16690713 16983998 17062856 19096730 19300954 19749125 203...

output:

34625599
124429384
6777445
131290365
6678470
49871059
66553258
6454284
21708820
121370217
35607366
174105325
104368353
109670206
51634557
139853724
12394875
33323649
99023406
37574454
96151472
19863121
26824834
143187458
30547128
17845129
106682462
137843559
27233605
130623028
178385333
112136570
11...

result:

ok 20000 lines

Test #131:

score: 27
Accepted
time: 5ms
memory: 4080kb

input:

108604505 486 20000
94449 210876 455788 541717 1153027 1229050 1610414 1657465 1693738 1868712 1881661 2125822 2800814 2942636 3462655 3588172 3709372 3924137 4857819 5346806 5605290 5737992 5930167 6132390 6767485 7112529 7214925 7303131 7771784 7806888 8457042 8496210 8550983 8846583 9157613 92247...

output:

19994602
19582340
33392811
47947519
19646112
19570376
17759780
53086145
25452512
40756140
19403267
808168
29959765
13080759
22081568
19875878
31802314
2319739
30127278
35647284
50144206
13015056
28783041
31897467
46955221
3044992
47271890
47443992
53957084
23343244
30598777
6290327
47790488
24625252...

result:

ok 20000 lines

Test #132:

score: 27
Accepted
time: 5ms
memory: 4148kb

input:

997424 6678 20000
298 326 666 909 1285 1667 1929 2051 2100 2166 2393 2608 2658 2791 2913 2996 3343 3684 3822 3844 4174 4218 4227 4258 4347 4420 4461 4523 4530 4567 4814 5167 5172 5364 5422 5676 5714 6230 6258 6283 6563 6593 6632 6900 7150 7384 7549 7613 7670 7831 7929 8034 8143 8227 8466 8505 8561 8...

output:

7894
152778
182362
398394
400052
155776
308051
475146
195001
394204
492613
10999
64748
483108
274134
411240
118725
263606
320983
480238
483787
494473
466180
177597
401000
112381
412155
209204
285908
88514
222256
460305
191812
206626
9430
151404
361467
75211
319139
28255
192531
266308
175599
27262
46...

result:

ok 20000 lines

Test #133:

score: 27
Accepted
time: 19ms
memory: 4764kb

input:

500000000 207709 20000
9326 12223 12891 14526 14877 18866 21777 25567 26647 27226 28788 28796 30797 34711 38701 40071 44735 45027 45440 49153 50417 50956 51697 52642 53994 54597 54978 60377 60950 61544 63813 64349 64400 67464 68875 70315 70631 72527 73374 73474 75154 80860 86615 89800 95932 96716 99...

output:

141059047
24799430
165673057
221028563
90202010
78800260
202425391
180691719
216064738
190998227
113722009
173749467
164351486
61621530
168087854
10617104
153450374
40858670
81552415
194116033
24642786
40694177
100238876
73834846
178368737
182176612
74036527
94581052
147963951
19361768
170086008
145...

result:

ok 20000 lines

Test #134:

score: 27
Accepted
time: 15ms
memory: 4664kb

input:

500000000 199515 20000
5349 10654 11517 12837 22555 28045 28909 29477 31101 33652 38169 40590 41358 43033 44835 46818 47854 49968 50594 51901 55065 56539 57177 57227 60780 61291 62349 66672 68255 70409 74655 74715 77126 77212 77399 78792 92758 95047 98139 98418 98941 104054 104626 106966 107634 1078...

output:

158840478
111800684
154422050
99368611
82546442
242390958
82756055
75196558
31882440
217814546
53984914
98265341
248909277
59254947
151042175
176305173
194992720
168835395
104581721
47332822
26874790
233094575
63375876
62147864
37590136
21679347
22540437
181386273
177852495
156577391
7980206
9365577...

result:

ok 20000 lines

Test #135:

score: 27
Accepted
time: 35ms
memory: 7076kb

input:

500000000 500000 20000
974 1153 1400 1524 1889 3305 3930 4298 5983 6676 9292 11255 11936 14705 14790 16250 16495 16872 16885 17792 22148 24722 24731 25987 26305 26882 27067 27397 30227 30232 30356 31519 32296 33367 33396 33621 33861 34735 35307 37049 39066 39184 40240 41248 41531 41591 42235 42695 4...

output:

23079191
187012274
132205494
229116411
151076375
165755004
39204553
20982642
229263825
70771635
152175215
28926762
57487115
140200855
29591321
67452923
225399805
44481250
25046585
210517715
202249017
238112589
89953980
56003685
127548034
244005958
33625932
221260032
145934614
115586865
127869602
157...

result:

ok 20000 lines

Test #136:

score: 27
Accepted
time: 35ms
memory: 7184kb

input:

500000000 500000 20000
1574 6029 7505 8027 8945 9099 9276 9340 10936 12421 12687 13040 13087 15328 16540 16862 17649 18669 19126 20168 20703 20944 21023 21396 24231 28115 29259 30800 31775 35856 36573 37521 38095 40020 40915 41323 42574 42839 43265 43596 44661 44866 45023 46029 46994 47468 47718 482...

output:

89732945
58822733
142888255
108732111
81496715
7149655
206800443
148508478
153830164
234973063
11005340
184401952
178308607
212233288
42561838
202055375
241824538
34790157
176571342
241278073
84048324
57134273
154436118
75623546
150876551
44176691
161028600
170721190
171949512
88020289
171934914
135...

result:

ok 20000 lines

Test #137:

score: 27
Accepted
time: 40ms
memory: 7060kb

input:

500000000 500000 20000
0 2876 3132 3290 4773 5640 5800 7671 8406 12782 14997 15778 18916 23301 24550 26039 27212 27627 29027 29408 30179 30356 32357 33572 33648 34000 34271 34615 34816 36236 40094 41026 43505 43609 44530 45160 45418 46861 49633 52394 53009 53350 54360 55129 56817 58398 58776 60937 6...

output:

129219683
16053181
102848079
33413950
181453070
168298977
145029005
149302513
55388592
153328190
239289861
90189492
74768399
151544248
133315395
70612876
32986645
70876598
111033676
51834320
136300981
100964223
165388152
208597527
67889896
213685955
214418591
236823559
138356999
31226992
109813701
1...

result:

ok 20000 lines

Test #138:

score: 27
Accepted
time: 40ms
memory: 7080kb

input:

500000000 500000 20000
111 759 1379 2344 3795 4079 5240 6402 7468 8398 8933 9937 10486 10599 10759 10994 12826 13328 15516 15546 15650 17942 19218 19561 19863 20154 20751 21134 21929 26353 26588 26717 29361 32270 32408 33303 33646 34380 34456 35013 38189 39720 41873 45415 51061 51797 52399 53550 537...

output:

87476786
110727403
106229080
62626463
150899402
214446014
180836789
125726977
40191299
26014192
140658364
29869491
32087069
228934764
123022966
87258944
59277613
192623347
225422022
183488753
88664017
171585193
96861039
245935430
79516420
32533392
80175089
165380659
2101630
17751954
225404719
158579...

result:

ok 20000 lines

Test #139:

score: 27
Accepted
time: 5ms
memory: 3788kb

input:

154276464 67504 100
234 369 978 2299 2711 7629 12136 14566 18202 18851 23963 24622 25592 26036 29454 32374 33362 35104 35210 41888 43632 47493 47988 49216 51201 53036 54359 54456 55950 59582 60371 60625 60855 63781 64189 65457 70914 82004 83297 89698 92343 94453 96863 98275 109829 111486 115885 1194...

output:

15699105
66445185
14812116
48216602
64123702
20522122
24251399
36214867
20957518
33003286
34454034
16969014
62513317
51164004
48822140
3447706
30712903
69556358
20808937
48266623
13352566
1695281
62510882
14837866
60866692
60477330
28191226
60842919
57514853
18329053
25646615
42765328
21858019
64692...

result:

ok 100 lines

Test #140:

score: 27
Accepted
time: 2ms
memory: 4076kb

input:

88774148 24640 1
2251 9188 11361 32069 32562 33668 40207 46347 48107 49406 68223 74560 79055 79246 81426 82036 82336 89553 92571 93390 98807 101121 103052 104109 111956 115770 117562 118340 118636 119071 119341 120309 125902 126031 127956 128840 136211 137838 144450 145554 150201 151187 154342 15517...

output:

40524454

result:

ok single line: '40524454'

Test #141:

score: 27
Accepted
time: 18ms
memory: 4444kb

input:

193646505 160765 20000
209 968 1220 3179 5672 6238 6557 6596 6897 7591 8709 8844 11611 12230 12479 14115 14526 15112 15364 16620 17110 20643 20957 21890 22380 28373 28572 30994 31490 34136 34564 35858 36275 36635 37015 37668 38273 39347 40150 40613 44640 45213 45405 47849 49178 50572 50980 51790 534...

output:

84927518
87565278
85842928
72795966
5342387
28903417
39789493
54867372
9792861
85780914
87181525
40145565
9872979
38300843
62326057
17440435
16041353
33368957
36710753
31140781
94945092
16509733
16203613
8517340
46191687
4840257
23793972
24779016
33196677
68102764
39528306
13337361
73657065
78647868...

result:

ok 20000 lines

Test #142:

score: 27
Accepted
time: 22ms
memory: 5024kb

input:

89649742 229467 20000
729 1280 1945 2106 2466 2914 3504 3506 3637 3898 4169 4739 4784 5174 5256 5743 7075 7485 8019 8032 8302 8808 8981 9149 10411 10622 10712 10771 11953 12801 13645 14059 14136 14603 14621 14728 14931 15530 15746 16061 16268 16591 17311 17329 17368 17735 18433 18515 19234 19952 202...

output:

29047608
36355235
3070935
24552154
31833645
26725274
37914646
31711342
9175779
2377649
23402419
12803237
21369337
21781763
34791695
15319965
15891373
38682501
26126373
37571496
33576105
30364433
44203636
1107140
43023731
37938234
25147880
24964949
37344894
38307313
28257383
19834496
5079083
6146606
...

result:

ok 20000 lines

Test #143:

score: 27
Accepted
time: 20ms
memory: 5756kb

input:

402531525 324471 20000
4664 6490 6673 7124 8846 8850 8884 9614 9659 10921 11077 11133 12583 13320 14199 15473 22722 24485 25634 27784 28027 28225 31028 31792 32819 32908 33778 33994 37212 37663 39353 40607 41433 41450 41707 42959 44158 45562 46688 46794 48752 49496 49854 51481 51927 53519 54001 5759...

output:

163465643
127664518
24736214
187248313
114630060
130837374
109629806
40664365
145197668
156673362
48694235
56252237
118754932
1148333
16897961
105337680
164949231
164135746
27220140
200751323
121005773
89497880
177894690
100947065
5889598
157444370
148669426
171719507
139920090
86344872
57895394
113...

result:

ok 20000 lines

Test #144:

score: 27
Accepted
time: 5ms
memory: 3788kb

input:

19680207 1 20000
18787545
23647625 10008972
30672398 20348840
38519963 18511597
36065341 22183261
19229474 39357811
10131504 21902913
29185850 14691476
11164270 35134638
30996522 4708815
29031188 32394829
14830278 30865912
27792023 19185866
15058721 18907329
25549160 17095748
14969671 20370065
23583...

output:

13638653
9356650
328160
5798128
1331989
11771409
13377972
10956390
13072707
3363641
11559108
8606157
3848608
8453412
5400394
9317926
8649762
5898124
461685
8278916
12284467
9831264
2741834
1739315
9241371
14221716
17011654
6021025
9389585
8654459
13175007
11849793
1852232
8094770
423889
3358569
2947...

result:

ok 20000 lines

Test #145:

score: 27
Accepted
time: 5ms
memory: 4080kb

input:

405226035 1 20000
87626961
150030562 364025261
417955229 238700802
523424987 366958940
621053744 647334097
289022399 584056998
463989364 638670771
67329671 503344975
208924058 751755519
62425700 131166113
138065951 267472906
542207919 207148660
712676770 158252752
615613455 684360236
641237381 25904...

output:

191231337
179254427
156466047
26280353
292599441
174681407
30789270
267620609
68740413
129406955
168876623
256028052
68746781
319798478
175199045
169058331
36493914
282705442
118778622
76106367
49190742
98263173
86143383
291231065
181564596
189311214
94910104
247819968
129616980
95909713
134348871
1...

result:

ok 20000 lines

Test #146:

score: 27
Accepted
time: 5ms
memory: 3728kb

input:

61450616 5 20000
12750 17661582 18621892 39383487 60318608
36784215 17084640
21584903 43339093
46776005 5176010
57820894 53479151
24827744 80804162
28086549 121045183
48758485 96427558
115566907 57072383
53828185 100819214
120361086 86959194
39095884 88778559
14579541 1623461
62241354 112503912
5089...

output:

19699575
21754190
19850622
4341743
6937507
29942598
13781544
9448543
14459588
28048725
12343148
12956080
11188059
12798852
27125058
6586131
26108502
17387619
29061155
22651185
17692864
22516303
8799976
7105339
19081737
12080649
457887
25813425
1497885
1646535
26293243
17169939
21262980
21704180
7416...

result:

ok 20000 lines

Test #147:

score: 27
Accepted
time: 5ms
memory: 3824kb

input:

309798645 74 20000
0 440079 1722636 8234848 9065037 9368201 11584117 12939581 14167773 20341453 23575359 23671835 31107055 54494958 59345013 61952414 63596044 64044449 65282031 72394375 83355263 87516738 96206643 99493303 99610770 100723747 100969273 101376995 102538087 104940933 107554397 112487550...

output:

35299001
43449995
109219729
127379326
65295316
103733107
44556193
124284184
63183821
91608463
147869157
86933741
18240826
70441191
35405902
130670697
12891258
138280796
106561740
99292511
143410902
23466031
102597998
13281412
10378906
66317405
67002878
10853266
68489591
142015549
57314382
149668578
...

result:

ok 20000 lines

Test #148:

score: 27
Accepted
time: 3ms
memory: 3764kb

input:

243130240 913 20000
950764 1667454 1667625 1765029 1965177 2152639 2484847 2843575 3023638 3546866 4674954 4692552 5278695 5814049 5847708 6590633 7020808 7368887 8162001 8249965 8636913 9321344 9383550 9939373 10575496 11268522 11339916 11607453 11797965 12140654 12281248 12327958 12422867 12437806...

output:

69525531
106281174
6612680
52702190
23317909
61569794
78152934
62568687
65877944
45481873
7495774
111651025
103500158
32451193
52663942
39755840
14073939
119237006
84302960
90839165
90772476
23433520
2352078
4516965
79714839
40841542
61093153
48749617
89548661
32959347
72923864
118067330
35140186
21...

result:

ok 20000 lines

Test #149:

score: 27
Accepted
time: 5ms
memory: 3780kb

input:

333549630 17 20000
1389798 17024303 88250616 146759792 148469542 157758674 159393488 164624357 167576432 169519081 213141172 237460546 243273547 251382258 262013342 292280152 295657844
291352987 145881413
435247351 317292780
180343746 51454401
381248235 40265999
329477598 142313012
132793826 4951345...

output:

145471574
117954571
128889345
53915999
146385045
28791093
68168296
88739732
31344980
9988657
127287158
66501425
46362024
18260853
33955255
119809997
120065241
78647494
103137574
98246332
147090099
104944026
65444194
49191616
152587726
55423542
40445399
118689884
85731179
18895178
124743223
69328169
...

result:

ok 20000 lines

Test #150:

score: 27
Accepted
time: 7ms
memory: 3820kb

input:

117581308 3889 20000
14377 69222 132147 145433 186278 209155 258741 263729 271424 272891 278904 321160 332866 347387 347545 353811 408253 458672 521705 546081 546842 565709 580185 594629 626377 638925 677606 709963 761072 791745 822547 921840 967086 974786 984826 998262 1000088 1001475 1025489 10394...

output:

6990196
20006116
12431092
32112214
57709166
29815397
36421558
57424870
47084606
54876209
20539048
32673110
46705131
9846177
25151079
10390006
30753176
30085196
29860757
34323299
27203013
17839670
56405382
49403412
5528067
51052896
33036013
37621002
33472951
7549807
54256838
3042719
36212745
25507131...

result:

ok 20000 lines

Test #151:

score: 27
Accepted
time: 0ms
memory: 3852kb

input:

4 1 5
1
1 4
1 5
1 7
1 2
1 6

output:

2
1
2
1
2

result:

ok 5 lines

Test #152:

score: 27
Accepted
time: 0ms
memory: 3792kb

input:

6 1 3
5
5 7
5 1
5 11

output:

2
3
1

result:

ok 3 lines

Test #153:

score: 27
Accepted
time: 0ms
memory: 3792kb

input:

4 2 4
2 3
0 2
0 3
0 6
0 7

output:

2
2
2
1

result:

ok 4 lines

Test #154:

score: 27
Accepted
time: 0ms
memory: 3860kb

input:

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

output:

1
3
3
3
2

result:

ok 5 lines

Test #155:

score: 27
Accepted
time: 0ms
memory: 3784kb

input:

500000000 4 3
543234 1234566 2300001 249999999
2334445 123567
6578996 12455726
3 269979899

output:

2210878
5876730
231106567

result:

ok 3 lines

Extra Test:

score: 0
Extra Test Passed