QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#461169#3101. Event Hopping 2egypt_ioi2024_01#32 1292ms39336kbC++231.6kb2024-07-02 16:43:112024-07-02 16:43:13

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Time Limit Exceeded

Test #1:

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

input:

1 1
1 3

output:

1

result:

ok single line: '1'

Test #2:

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

input:

2 1
2 4
3 7

output:

1

result:

ok single line: '1'

Test #3:

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

input:

3 1
2 5
3 5
4 7

output:

1

result:

ok single line: '1'

Test #4:

score: -7
Time Limit Exceeded

input:

99999 93097
40044 40749
44538 45365
46530 47401
52845 53481
59519 60065
86226 87059
88353 88992
95665 96502
95669 96575
100446 100968
121870 122544
130836 131540
146294 147230
151177 151970
160381 161376
164174 165119
166582 167438
169062 169687
173200 173849
177329 178217
189213 189811
249372 25029...

output:


result:


Subtask #2:

score: 1
Accepted

Test #47:

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

input:

1 1
134842099 137944073

output:

1

result:

ok single line: '1'

Test #48:

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

input:

2 2
4015595 884953730
519508315 726912949

output:

-1

result:

ok single line: '-1'

Test #49:

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

input:

3 2
551691302 800582045
14063803 52897269
153641504 567834643

output:

1
2

result:

ok 2 lines

Test #50:

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

input:

18 3
157893686 958635898
790021767 976682032
534783017 706987897
216566011 510148270
288661613 856715472
81126924 420966670
9734253 823219818
77427078 241270378
182953794 928971032
65710916 937359407
159217847 343023570
266169092 635952191
94867522 407392584
298640819 490028599
281580042 514089998
6...

output:

2
3
4

result:

ok 3 lines

Test #51:

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

input:

19 3
345121760 363569961
369142474 697961114
204455374 777512357
278051598 780834857
119744682 610142516
112692534 284271720
530820418 613805256
666599238 970772442
684066330 747151742
52464000 153949333
361766230 921325388
34600363 168745634
119418778 738281466
828841976 976561834
257913352 2579536...

output:

1
2
6

result:

ok 3 lines

Test #52:

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

input:

20 3
226617517 417144410
401110226 504506272
204308913 972565478
100780114 930332684
473716139 730386187
327436800 871728821
662616072 881801440
469971234 769277127
437331467 913865677
641546412 700063729
82089639 830256714
384651823 502387376
558881974 905373190
468189379 998408858
9103683 60217281...

output:

1
7
18

result:

ok 3 lines

Test #53:

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

input:

20 5
715591101 817706977
777008847 930020190
379125190 717746290
308826535 651449374
799848635 899870053
173402733 393191194
565584335 789226348
291163241 758381981
249473019 374801668
294956234 880404922
451362750 913870571
98855617 246302398
339866606 382702111
293058132 409201146
478015003 708631...

output:

1
9
12
15
19

result:

ok 5 lines

Test #54:

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

input:

20 4
95564966 475651640
544140915 921414489
36636943 545028649
269212181 518161723
368415853 600482753
416749483 825099524
704848425 946709199
145082659 465308089
751497619 765279722
452763328 557958381
643817392 876292284
353226095 933184330
466610247 590597228
29324927 65589713
155598093 306733984...

output:

5
7
14
15

result:

ok 4 lines

Test #55:

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

input:

20 2
341059917 968468550
619575412 657744605
362725213 784431788
79002877 857963719
636336680 943339572
282572479 300370019
213849085 706084423
315706132 851874320
740367416 998763448
113510482 521411850
198080835 487564765
29193064 86493364
488295690 701227663
351650597 899167999
437802529 73566590...

output:

1
6

result:

ok 2 lines

Test #56:

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

input:

20 1
827468447 879951302
735432164 759558988
269959865 944012171
67243577 84278317
805433568 936534843
171608293 591686301
112362102 822334845
410116008 619648090
306041507 327894522
360193096 488922828
417005225 834550228
872712520 873151446
472785468 800113380
39268216 894210474
600856133 91169444...

output:

1

result:

ok single line: '1'

Test #57:

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

input:

20 9
18246520 289037312
223590378 904221984
158468076 685664873
661343077 978347160
435186112 640627800
559466880 559927584
45242916 566596015
130290765 300200349
175183463 434730463
75064355 595211002
333621902 449961207
28044312 78011568
267319532 981800089
579543582 623250773
501315035 549454467
...

output:

-1

result:

ok single line: '-1'

Test #58:

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

input:

20 4
282915225 425599000
46844071 877724908
331562754 774194013
454952275 729482745
26829711 957331160
627282472 841455868
100114358 781547255
150014807 274089000
534690006 980470663
541821180 599376720
84150518 232318480
4457533 168338098
28542916 343576455
94961278 964757965
1021672 802156769
1412...

output:

1
6
8
10

result:

ok 4 lines

Test #59:

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

input:

20 3
568423024 732950395
30698730 953476873
240194350 760469817
571506747 960258324
142530756 898809811
502816961 572446466
63299466 595327108
441383100 954106794
401449920 893452390
131382436 615911903
103318462 704161744
17001604 744184311
355982562 921938859
277739118 448466769
852604059 87135217...

output:

1
14
15

result:

ok 3 lines

Test #60:

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

input:

20 4
729581552 843936903
595777889 662269624
434082235 904888330
189209392 706890360
122057607 566242764
12655119 862773552
253295242 267145374
514009091 646726110
699170128 892329802
139765740 798881549
465088674 483212263
438274771 843531949
551372681 969365825
370571050 441985295
369851925 695022...

output:

1
2
7
11

result:

ok 4 lines

Test #61:

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

input:

20 3
52680030 171567270
562416436 932178589
180457200 874534710
57962547 619926504
514034951 735903893
569357027 949556658
96546655 769067522
156273105 550639233
102800728 342367246
341675981 994824681
12457939 294153271
13450385 307425366
90257349 383467364
29966544 411684432
69951674 186314264
223...

output:

-1

result:

ok single line: '-1'

Test #62:

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

input:

20 9
18 22
2 5
28 31
21 25
25 27
3 6
36 39
22 26
8 12
27 31
27 29
32 36
14 18
16 20
22 26
10 14
17 21
13 17
15 19
37 40

output:

2
3
4
5
7
9
12
17
18

result:

ok 9 lines

Test #63:

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

input:

20 8
14 16
32 36
12 16
11 13
32 36
11 15
8 11
27 31
17 21
11 14
10 12
32 35
14 16
10 12
27 30
8 12
36 39
13 15
4 7
8 11

output:

1
2
4
7
8
9
17
19

result:

ok 8 lines

Test #64:

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

input:

20 5
8 10
16 20
14 17
26 30
26 29
16 20
8 12
7 9
21 25
31 34
16 20
14 18
22 24
26 29
12 16
6 9
7 9
26 30
17 21
27 30

output:

1
2
4
9
10

result:

ok 5 lines

Test #65:

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

input:

19 9
7 10
14 17
17 20
19 21
37 40
19 23
21 24
17 20
26 28
14 17
26 30
36 40
23 25
27 29
3 7
22 25
6 9
22 25
10 13

output:

-1

result:

ok single line: '-1'

Test #66:

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

input:

20 9
22 25
29 31
15 17
21 25
14 18
21 25
37 40
24 28
5 9
31 35
37 40
5 9
17 21
5 7
15 18
34 37
16 19
6 10
7 11
33 35

output:

-1

result:

ok single line: '-1'

Test #67:

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

input:

20 17
845269015 850357565
231570833 238492480
112075343 117449946
332830039 342056906
888759754 896832046
12792516 19353665
142051900 147667172
535996252 545054726
746039922 755668317
14144485 23611147
478226018 488214529
566689172 574405398
203948947 210298368
289137613 296782362
492823093 50197134...

output:

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

result:

ok 17 lines

Test #68:

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

input:

20 15
14188856 19236114
98742802 106752117
24269095 29763729
643363334 650430602
640667308 647978576
977081895 982348536
745449811 751115078
498241588 506936783
527053854 533674727
491394449 500443949
173465864 181340285
697167305 702838894
494029651 501636657
356910520 365788783
450134494 457312713...

output:

1
2
3
4
6
7
8
9
11
12
14
15
16
17
18

result:

ok 15 lines

Test #69:

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

input:

20 12
563046220 568800423
199343954 205146700
914428529 921389051
770854212 778944781
293251360 301031517
752099979 757638337
414657306 422232787
418601435 427149870
720794559 729165510
977858157 984913657
140764201 146705765
31266372 40564939
160980681 169658134
856117526 862237237
140519584 147162...

output:

1
2
3
4
5
6
7
9
10
11
12
13

result:

ok 12 lines

Test #70:

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

input:

20 17
889180138 897645327
738509954 745477991
528540397 538119158
378206912 383476822
79879358 86001857
98066197 103959366
640908142 649924188
524017315 531755079
979262559 988488803
789090356 797993258
782717536 789923836
267087164 272268465
28139018 33712559
379981686 387166408
400347925 406679332...

output:

-1

result:

ok single line: '-1'

Test #71:

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

input:

20 18
561486485 569818195
630359186 636475010
742947739 748730836
366786866 372238382
741166510 746356459
980930968 989331451
907461849 915230070
5726074 14451679
866818884 872405363
819511837 827958204
712517924 722136545
870083014 876845261
35270659 40840598
711697632 718619034
85840159 92347641
1...

output:

-1

result:

ok single line: '-1'

Test #72:

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

input:

20 20
58260057 75328425
75328425 93791372
93791372 93883091
93883091 152718294
152718294 186033899
186033899 207919883
207919883 270240750
270240750 288647403
288647403 357864905
357864905 381181754
381181754 386254557
386254557 432675450
432675450 446987413
446987413 451012965
451012965 492937493
4...

output:

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

result:

ok 20 lines

Test #73:

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

input:

20 19
57471590 160037396
160037396 194076047
194076047 261241448
261241448 311172263
311172263 403739986
403739986 426302161
426302161 455690634
455690634 482534841
482534841 516724753
516724753 533199987
533199987 574790581
574790581 579061246
579061246 579834662
579834662 585842666
585842666 59903...

output:

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

result:

ok 19 lines

Subtask #3:

score: 31
Accepted

Test #74:

score: 31
Accepted
time: 3ms
memory: 4872kb

input:

3000 57
226083340 261990234
392684356 462929590
468018811 841719892
495096853 606046097
196983814 256423598
331199122 967656486
802593662 931108452
74501453 679054962
294344294 752837262
295708332 547261648
265421699 652708933
272959087 727136240
165667761 846917534
61770748 157663302
608516043 8492...

output:

50
85
104
139
173
189
257
273
297
327
347
374
411
543
600
665
686
750
766
850
971
977
990
1040
1069
1074
1109
1183
1226
1231
1316
1440
1508
1597
1611
1670
1676
1774
1811
1822
1885
1968
2005
2103
2153
2271
2304
2416
2445
2562
2593
2608
2690
2798
2873
2884
2952

result:

ok 57 lines

Test #75:

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

input:

3000 52
515391161 611274809
241579177 794330740
10171859 421070901
191803444 462515964
789307312 942558211
168283015 749632607
741578406 748242944
727114778 888235899
285915154 538783207
740946890 927609854
511153062 526293212
202320202 315438522
60716314 641460650
4714115 322423665
680445730 761796...

output:

1
7
192
299
300
315
336
345
359
372
452
465
492
510
527
562
584
760
800
901
931
956
1075
1130
1170
1252
1281
1302
1363
1390
1427
1451
1474
1483
1555
1579
1635
1668
1788
1926
1971
2031
2052
2075
2121
2219
2226
2241
2421
2541
2682
2859

result:

ok 52 lines

Test #76:

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

input:

3000 50
164570698 977045956
184755663 365443392
603003602 688612912
69841518 845988325
124418966 495851703
92585079 221534905
66139125 492051425
11421559 470042732
353246878 519346251
394298743 656627500
91775697 487156113
216248411 680156936
102411138 118357679
310656407 421025471
226521211 7328919...

output:

2
13
31
63
71
73
107
171
204
212
235
242
282
315
338
363
385
498
513
533
597
602
741
1005
1366
1370
1400
1437
1453
1620
1631
1641
1660
1677
1753
2013
2052
2095
2188
2193
2208
2273
2384
2403
2532
2536
2540
2617
2727
2882

result:

ok 50 lines

Test #77:

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

input:

3000 26
420404814 607862506
424467321 435523425
441190777 977565387
171426323 268399128
98674944 937744436
65655455 205658000
102598650 388620400
594769046 940080999
63712781 445910235
378752716 930132171
428633245 659202337
232544464 994494247
6080714 60362625
221134868 345936051
808753899 83968712...

output:

1
4
13
15
26
27
30
42
81
105
114
149
301
558
806
822
843
904
1050
1169
1342
1373
1381
1930
2233
2421

result:

ok 26 lines

Test #78:

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

input:

3000 13
102826206 602027329
434931994 772339872
413413031 694464267
314395105 702742251
503992096 615714991
524571226 706613683
435807387 612902646
578112010 649125385
844903761 848000998
341521417 363587344
97482358 959069283
521677223 694511265
640709856 675605818
42442983 875334044
857624837 9646...

output:

1
9
13
15
43
152
165
309
333
547
977
1141
1657

result:

ok 13 lines

Test #79:

score: 0
Accepted
time: 26ms
memory: 4708kb

input:

3000 70
198876171 633452260
354684172 825494360
176550414 579846248
37743187 608475834
450639405 902539433
280219847 870211150
464249200 742260813
41925939 766325361
97120779 711013020
574107337 735065952
246344901 762902043
672906006 685387866
244479077 865874730
648084393 685613914
158950527 67355...

output:

-1

result:

ok single line: '-1'

Test #80:

score: 0
Accepted
time: 26ms
memory: 4640kb

input:

3000 61
288199641 988839430
555844621 886872865
528143584 789134190
562722637 879682817
56509608 381493312
229625999 946569378
54106433 199826523
26672970 471173920
182843886 848260651
146884261 191667110
696155489 947691429
228312645 368033961
423044046 764707825
271023642 485950519
153931729 96748...

output:

-1

result:

ok single line: '-1'

Test #81:

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

input:

3000 2931
717499499 717506267
392679825 392686341
694444934 694453409
780438871 780445478
338800501 338810163
932318897 932326372
571463112 571469934
657811272 657818137
853170401 853177063
980130048 980136614
470824555 470829577
586203411 586209503
56106755 56114626
830789358 830795307
790344400 79...

output:

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

result:

ok 2931 lines

Test #82:

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

input:

3000 2628
241730947 241740288
658483880 658490240
807041193 807049477
842592817 842600016
987698454 987704778
731407174 731414105
645086761 645095059
384663701 384670491
782262851 782268893
459848253 459858000
274935402 274944725
825636713 825642267
436165777 436173314
875901828 875911426
878615751 ...

output:

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

result:

ok 2628 lines

Test #83:

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

input:

3000 1960
367683881 367761448
215927495 215996140
123327945 123399581
517814503 517905591
445638988 445733217
474509686 474567834
835839513 835923838
196178279 196228647
716259021 716336050
686584694 686683895
703996530 704060207
160293571 160373918
589183152 589240014
582673713 582753879
332295166 ...

output:

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

result:

ok 1960 lines

Test #84:

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

input:

3000 2461
453531793 453621247
558539257 558594171
731739897 731806619
975060474 975133124
612632248 612702460
746803150 746876746
309037653 309111171
158550993 158628126
91959293 92023150
682539837 682632482
78195454 78293782
448833562 448893692
406764747 406838753
439840691 439925982
463920530 4639...

output:

-1

result:

ok single line: '-1'

Test #85:

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

input:

3000 2461
448202517 448273218
597685396 597738816
898391908 898487853
551203413 551292049
538903715 538967314
960936285 961004894
317177569 317272788
227411137 227497567
50871215 50945345
780540596 780598452
997296850 997387679
813579782 813657678
494940859 494999468
133765968 133849544
715564610 71...

output:

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

result:

ok 2461 lines

Test #86:

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

input:

3000 2219
416620215 416702150
68241497 68295074
199770863 199825326
509726913 509815489
779096757 779176346
50301373 50395109
680442068 680513838
10672027 10753946
419155554 419225228
27993477 28074613
202777466 202848428
898431046 898501606
855439662 855516089
49972085 50058137
132037605 132105941
...

output:

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

result:

ok 2219 lines

Test #87:

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

input:

3000 1971
273289960 273356035
645494918 645563363
294116810 294199291
654712464 654787915
325898403 325952171
900639603 900728124
214507936 214579081
891135731 891193900
184697938 184797874
513603004 513656867
547883255 547961511
5123630 5222722
402930073 402994785
781538375 781602407
110940514 1109...

output:

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

result:

ok 1971 lines

Test #88:

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

input:

3000 2436
530935185 530988618
580187755 580240329
716942726 717012471
678190163 678283109
867364235 867425954
769776432 769859020
785270305 785322268
546531856 546591590
506863712 506938474
776239055 776326129
587366299 587464235
657153809 657240082
864540308 864638331
722990726 723046932
680337120 ...

output:

-1

result:

ok single line: '-1'

Test #89:

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

input:

3000 949
194920414 195903000
644679751 645454019
497467216 498253834
405122431 405961817
218320386 219078779
322523221 323031550
36276543 36798937
461861332 462815590
898761987 899501902
105276665 105978705
135929137 136486543
498864424 499613435
15581270 16269350
101987601 102536809
904757589 90571...

output:

2
4
5
6
7
8
10
11
12
13
14
15
16
17
18
20
21
22
23
24
26
27
29
30
31
33
34
35
36
37
40
41
42
43
44
45
46
49
50
51
53
54
55
56
58
59
60
61
62
64
65
68
69
70
71
72
73
76
78
79
80
81
83
85
87
88
89
91
95
96
97
98
102
103
104
105
106
107
110
111
116
117
118
120
121
124
126
127
128
129
130
131
132
133
13...

result:

ok 949 lines

Test #90:

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

input:

3000 852
8369209 8978440
26311257 27082715
933705072 934380857
827878226 828562378
366742358 367583321
68546569 69105189
971561637 972399204
765332686 766287459
773153255 774015481
61810651 62574804
918056514 918570559
140263391 141090102
52520069 53372496
884179770 884741439
956753275 957746050
226...

output:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
31
32
33
35
36
37
38
39
40
42
43
45
46
47
48
49
50
51
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
70
71
72
73
74
75
76
77
79
80
81
82
83
85
86
87
88
89
90
91
92
94
95
96
97
98
99
101
103
105
107
108
109
110
112
113
114...

result:

ok 852 lines

Test #91:

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

input:

3000 739
497750401 498441996
267013399 267807392
918205023 919057677
326829272 327494027
753580445 754547251
35771377 36578633
808830658 809513795
56904078 57682462
887893164 888453875
329471353 330094906
100045968 100620573
896750067 897291941
283453808 284236716
324367485 325131611
770084423 77091...

output:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
42
43
44
45
46
47
48
49
50
51
53
54
55
57
58
59
60
61
62
63
64
65
67
68
69
70
72
73
74
75
76
77
78
79
80
82
83
84
85
86
87
88
89
90
91
92
93
96
97
98
101
102
103
104
106
107
108
109
110
111...

result:

ok 739 lines

Test #92:

score: 0
Accepted
time: 24ms
memory: 4708kb

input:

3000 925
420932447 421626010
904558008 905537878
655974505 656877253
514778277 515477813
199954685 200575289
293749166 294729902
179658408 180211242
326172243 326963713
527623498 528591366
65623235 66554247
399423541 400202725
520524243 521395427
283044209 284022490
179452315 180250519
505572370 506...

output:

-1

result:

ok single line: '-1'

Test #93:

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

input:

3000 153
587095114 596864273
670972487 676705997
191989357 198259167
673812587 683735533
245531196 254685257
225530225 234668988
452202357 458499572
272497340 280081758
87784636 93103291
670723843 678834868
50697649 60313556
951622145 958709103
382858098 389205982
676506551 681615487
384746612 39319...

output:

2
3
7
8
9
12
16
18
28
29
34
36
51
52
61
64
83
89
113
121
133
135
151
159
169
171
179
183
189
199
205
207
213
216
220
225
226
232
236
240
248
274
278
315
318
325
329
350
367
368
378
379
392
416
417
440
455
458
473
474
482
527
542
547
551
557
560
598
613
663
698
734
755
756
771
775
784
798
812
827
829...

result:

ok 153 lines

Test #94:

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

input:

3000 135
66885624 74104557
821414044 829087206
540699843 549726223
555899692 561078438
398755672 406020478
205882941 215435650
466732518 472842610
300990520 307907728
682356575 690744695
108052241 113305743
272402701 281220339
615723139 624160467
511470164 520171163
237176338 246766146
126512397 133...

output:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
19
21
22
23
24
25
26
27
28
36
37
38
42
44
47
48
52
53
55
64
70
79
81
87
91
99
104
108
119
120
129
139
141
153
161
178
188
200
206
208
229
232
242
255
270
276
298
315
335
347
364
417
429
432
450
467
480
483
496
518
539
553
556
577
578
589
619
634
640
661
672
...

result:

ok 135 lines

Test #95:

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

input:

3000 119
14458542 21844057
164839444 174229019
15409606 22270150
32376420 37743308
991477752 997728876
721021697 727700796
139296352 149247886
52968349 59742380
634812813 642348291
912839693 918945516
574242833 580891995
846393269 852631229
108377676 118035426
751791593 758482235
192318217 201297956...

output:

1
2
4
5
6
7
8
9
10
11
12
13
14
15
16
19
20
21
22
23
24
25
26
29
30
31
32
35
36
38
39
40
41
42
43
45
46
47
48
49
50
56
59
61
63
64
69
70
71
72
73
76
82
84
86
87
89
90
95
101
102
104
106
110
112
118
123
128
131
149
151
155
164
168
174
175
177
186
205
222
242
260
291
296
298
300
317
325
360
376
436
481...

result:

ok 119 lines

Test #96:

score: 0
Accepted
time: 30ms
memory: 4640kb

input:

3000 151
476273765 485191811
728245332 737058902
289976217 298935950
663781569 673172371
748035322 753155742
63821194 69483396
193742953 201456928
308574266 314977699
883471433 890660435
32480997 41062430
913665000 920375502
582916096 590506484
502473679 507842105
770519594 779951926
868534486 87708...

output:

-1

result:

ok single line: '-1'

Test #97:

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

input:

3000 18
626228169 725462861
407984604 469727724
496462860 581426714
349402534 444725282
851576033 926964137
122559079 198333690
10516020 62745202
487022010 559792623
855212149 947900038
215521874 276667908
784521821 880702641
780738618 858450229
359331303 415600606
595034666 678823310
287408528 3419...

output:

7
15
24
198
246
497
765
1056
1065
1093
1761
2235
2280
2374
2612
2733
2772
2942

result:

ok 18 lines

Test #98:

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

input:

3000 17
51724110 123484345
576592988 636428271
600018459 658996800
238522792 311046511
78712172 169948003
481839811 554918345
883289292 974508498
817459393 869470842
8164804 93319273
13757914 110340582
539312692 621165605
583764195 669814808
603091776 670342368
215171402 269702052
900841098 97569590...

output:

2
8
9
93
205
242
348
540
1009
1535
1572
1663
1734
1854
1919
2360
2409

result:

ok 17 lines

Test #99:

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

input:

3000 14
338309257 391881083
731139079 830007360
869727747 929678461
390955786 444907914
267414436 319380458
868898573 955892832
483074302 571864191
366044466 419314941
83724165 159912013
412776485 488069098
427381885 484866879
257163375 350857004
257343424 311754437
157224579 221603757
582175530 638...

output:

1
2
3
5
9
10
18
41
97
461
839
1458
1750
1758

result:

ok 14 lines

Test #100:

score: 0
Accepted
time: 33ms
memory: 4940kb

input:

3000 19
814425216 892029587
337824132 411852724
731518837 829919458
123115390 194055950
627387987 685141124
310040043 373995220
408842867 496081307
905952989 998467966
728582451 803543185
369461294 461312810
125788557 201661655
59055678 111939661
381783704 470266639
870969920 942464280
7088303 78994...

output:

-1

result:

ok single line: '-1'

Test #101:

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

input:

3000 3000
285375 361742
361742 1107858
1107858 1255748
1255748 3857978
3857978 4249535
4249535 4273015
4273015 4510876
4510876 4673623
4673623 5291542
5291542 5296509
5296509 5352452
5352452 5437629
5437629 6167983
6167983 6367767
6367767 6409548
6409548 6543578
6543578 6655685
6655685 6803906
68039...

output:

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

result:

ok 3000 lines

Test #102:

score: 0
Accepted
time: 13ms
memory: 4768kb

input:

3000 2999
336072 629690
629690 738675
738675 1058078
1058078 1148116
1148116 1281217
1281217 1560365
1560365 2068319
2068319 2191153
2191153 2964384
2964384 3431080
3431080 3439452
3439452 3874384
3874384 3929919
3929919 4340843
4340843 4642499
4642499 5821660
5821660 6082017
6082017 6208666
6208666...

output:

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

result:

ok 2999 lines

Test #103:

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

input:

3000 2966
881439 1659176
1659176 1835459
1835459 2140867
2140867 2297845
2297845 2606845
2606845 2609166
2609166 2810935
2810935 3195899
3195899 3972603
3972603 4014901
4014901 4428975
4428975 4533556
4533556 4587460
4587460 5388358
5388358 5393800
5393800 5476594
5476594 6086859
6086859 6844551
684...

output:

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

result:

ok 2966 lines

Test #104:

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

input:

3000 2905
35556 86988
86987 467608
467608 817105
817105 1780295
1780295 2753753
2753753 3047565
3047565 3297187
3297187 3410856
3410856 3459929
3459929 3542637
3542637 3896915
3896915 4936654
4936654 5039919
5039919 5614735
5614735 5914320
5914320 6142936
6142936 6502585
6502585 6688477
6688477 7439...

output:

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

result:

ok 2905 lines

Test #105:

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

input:

3000 2856
349205 517059
517059 1453540
1453540 1638500
1638500 2395041
2395041 2728810
2728810 2821103
2821103 3035276
3035276 3251608
3251608 3962856
3962856 4389756
4389756 4553820
4553820 4825910
4825910 5443575
6384774 6387166
5443575 6384774
6387166 6564665
6564665 6651061
6651061 7140027
71400...

output:

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

result:

ok 2856 lines

Test #106:

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

input:

3000 2800
412394 662505
662505 1061638
1061638 1308775
1308775 1412317
2026845 2107180
1412317 2026845
2107180 2346086
2346086 2641994
2641994 2642056
2642056 3207689
3207689 3275120
3275120 3338186
3338186 3716783
3716783 3800432
3800432 4021953
4021953 4383326
4383326 4455668
4455668 4496646
44966...

output:

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

result:

ok 2800 lines

Test #107:

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

input:

3000 2739
165373 830542
830542 1561705
1561705 1713447
1713447 1942206
1942206 1992895
1992895 2276270
2276270 2488781
2488781 2584956
2584956 3327200
3327200 3360165
3360165 4118551
4118551 4399856
4399856 4486655
4486655 4561731
4561731 4698291
4698291 5108617
5108617 5655350
5655350 5682998
56829...

output:

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

result:

ok 2739 lines

Test #108:

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

input:

3000 2673
535542 909360
909360 1022340
1022340 1266542
1266542 1312267
1312267 1627143
1627143 1629778
1629778 2065004
2065004 2759215
2759215 3492939
3492939 3566207
3566207 3633393
3633393 3691801
3691801 3903192
3903192 3913523
3913523 4475637
4475637 4826581
4826581 5090379
5090379 5278803
52788...

output:

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

result:

ok 2673 lines

Test #109:

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

input:

3000 2384
774212 872908
872908 939310
939310 1197289
1197289 1991234
1991234 2256835
2256835 2321951
2321951 2839820
2839820 3313144
3313144 4350840
4350840 4442173
4442173 4558814
4558814 4721246
4721246 5072159
5072159 5769307
5769307 5980021
5980021 6731712
6731712 6854996
6854996 7076879
7076879...

output:

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

result:

ok 2384 lines

Test #110:

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

input:

3000 2971
114064 956241
956241 1773935
1773935 2628603
2628603 2714112
2714112 2894415
2894415 2989744
2989744 3071872
3071872 3335828
3335828 3601789
3601789 3758760
3758760 4619067
4619067 5344028
5344028 5594827
5594827 5781971
5781971 6884695
6884695 7513902
7513902 7843120
7843120 7910064
79100...

output:

-1

result:

ok single line: '-1'

Subtask #4:

score: 0
Time Limit Exceeded

Test #111:

score: 61
Accepted
time: 1292ms
memory: 39240kb

input:

100000 361
136798318 785362988
255943758 535488232
175203444 266819907
766993466 893575347
67274251 589651108
662289594 883406317
830803801 849703610
729398668 798198453
202605534 677648797
66407931 925909114
174421361 601553812
522629146 701284080
136544340 295925673
299796891 499869765
736583725 8...

output:

42
102
185
215
660
950
1006
1623
1980
2396
2561
3016
3096
3729
3924
4119
4471
4619
4677
5229
5380
5400
5430
5681
5889
5901
5924
6013
6031
6043
6049
6316
6365
6483
6510
6575
7327
7492
7798
7833
7867
7954
7984
8089
8092
8237
8885
9212
9714
9971
10114
10190
10242
10260
10265
10321
10533
11184
11295
115...

result:

ok 361 lines

Test #112:

score: 0
Accepted
time: 854ms
memory: 39224kb

input:

100000 328
269692358 997698065
516351186 607170799
899165316 935984256
231654824 951113023
397634275 844276634
272944023 356674362
331036300 591789552
534270410 758375903
257707030 473980095
317825664 516882620
610579169 989404143
101902362 760414607
698174500 729348168
91656793 503436924
534091914 ...

output:

2
41
110
127
301
353
368
542
632
984
1394
1776
1932
2009
2051
2284
2584
2910
3083
3223
3445
3641
3715
4307
4467
4551
4602
4653
4900
5174
5601
5642
5748
5905
5910
6444
6547
7011
7070
7477
7713
7954
7965
8034
8066
8161
8235
8362
8527
8582
8807
8947
9051
9053
9329
9647
9689
9712
9807
9851
9916
10022
10...

result:

ok 328 lines

Test #113:

score: 0
Accepted
time: 623ms
memory: 39332kb

input:

100000 292
473961621 864888449
190522959 820646665
9492513 22301217
37064228 860062372
391795076 902791815
197180141 731578247
474804419 869235660
337420840 436563026
11453242 873644167
75360028 186126449
31699663 787244799
767030400 822993892
109557343 876905381
31823632 671368043
747618025 7999011...

output:

3
8
12
18
25
68
258
271
431
671
746
759
958
1130
1230
1847
2037
2193
2205
2448
2594
2746
3130
3188
3824
3896
4053
4208
4356
4551
4673
4790
4836
5178
5205
5231
5382
5565
5613
5814
5916
5980
6338
6440
6821
7045
7378
7553
7584
7615
7703
8766
8839
9191
9224
9749
9796
9800
9972
9988
10285
10296
10395
104...

result:

ok 292 lines

Test #114:

score: 0
Accepted
time: 309ms
memory: 39152kb

input:

100000 146
175643977 458162947
122110004 727270078
24786112 260954842
378646915 422692851
377845733 473430752
468331006 663764144
327593225 737427150
115723835 155636492
269251393 797888967
389252318 897957255
294924161 560923471
178959541 409597437
220814553 509182863
77416516 651426679
447529688 6...

output:

1
6
8
27
42
99
139
282
593
638
1498
1954
2189
2288
4171
4305
4554
4856
4868
5213
5937
6482
6599
7492
7533
7702
7724
7835
7990
8151
8501
9545
10202
11614
12938
13407
13837
14131
14484
15053
15176
15606
15895
16102
16185
16796
16976
17542
17882
18864
19357
19477
19478
20381
20680
20848
22319
24436
245...

result:

ok 146 lines

Test #115:

score: 0
Accepted
time: 255ms
memory: 39336kb

input:

100000 73
471315639 579688376
73440809 909550586
759672613 860952046
499195004 718627966
236201261 770008372
100210626 445253931
416166676 960255314
616242371 848806264
137142775 925433124
125434924 236893487
333557018 512133009
855283884 890613490
554762441 630311858
61488866 231607852
424705519 48...

output:

1
3
6
20
29
44
60
79
96
297
434
698
883
904
1549
4376
6599
7205
7681
8413
9369
11066
11578
14161
15267
17040
18750
20414
23432
24491
24836
26136
27044
28237
28824
29434
30047
32389
34359
36857
38954
39156
39268
41554
47253
48535
48950
49012
49889
51613
51764
52209
52747
54204
54511
56706
57029
57065...

result:

ok 73 lines

Test #116:

score: -61
Time Limit Exceeded

input:

100000 449
644158539 748655897
114191306 880648021
134735903 823826742
464626595 851003711
495548403 882519143
671995246 859736434
215469445 398614608
363408156 397305983
101857521 925632267
82075442 522481883
252114434 722683422
116631698 349587141
128286913 202260986
261266779 958361998
465162344 ...

output:


result: