QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#310449#7181. Graph CutsZhangYiDeTL 369ms99636kbC++202.6kb2024-01-21 14:22:562024-01-21 14:22:56

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 8080kb

input:

4 5
1 2
1 3
1 4
2 3
2 4
10
+ 1
+ 2
?
?
?
?
?
- 2
?
?

output:

4
5
2
3
0
1
0

result:

ok q=10

Test #2:

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

input:

0 0
0

output:


result:

ok q=0

Test #3:

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

input:

0 0
1
?

output:

0

result:

ok q=1

Test #4:

score: 0
Accepted
time: 206ms
memory: 6064kb

input:

1000 2000
1 50
1 88
331 1
1 352
1 497
2 32
2 282
550 2
989 2
334 3
3 665
4 38
4 69
4 343
4 451
589 4
917 4
89 5
5 162
675 5
681 6
7 22
127 7
7 592
7 672
787 7
8 310
107 9
9 137
184 9
9 244
378 9
446 9
9 658
883 9
65 10
75 10
414 10
10 468
686 10
245 11
269 11
11 386
403 11
493 11
394 12
493 12
565 1...

output:

1803
626
916
917
518
1349
147
148
145
1128
1046
843
619
1415
398
399
397
396
1333
1337
733
1746
413
1283
707
1622
1969
262
263
264
265
1880
269
1182
606
1406
73
1043
1814
1850
1917
1928
1636
1877
1838
1857
1212
8
9
1789
103
613
720
833
838
998
1366
1364
1365
1784
1781
1783
1892
996
839
660
1119
1990...

result:

ok q=100000

Test #5:

score: 0
Accepted
time: 286ms
memory: 97792kb

input:

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

output:

19427

result:

ok q=100000

Test #6:

score: 0
Accepted
time: 326ms
memory: 71192kb

input:

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

output:

81616
93617
29071
93667
93673
18970
89131
93590
59101
43291
44293
69925
93683
62170
88246
40918
35668
93652
75261
61896
34591
93677
93640
93595
87325
93676
18568
9471
93623
63256
2551
83995
73236
17356
20170
93660
19771
66160
93686
46270
93613
93622
32410
75918
38496
55911
48531
93631
17761
72310
89...

result:

ok q=100000

Test #7:

score: 0
Accepted
time: 357ms
memory: 46368kb

input:

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

output:

64210
36620
11045
220
1109
1552
1994
2435
2875
3314
3752
4189
4625
5060
5494
42164
65785
665
56969
74115
40115
74190
60952
55795
74228
74103
74165
74117
74249
74031
25535
74191
23989
74034
5927
74077
31927
74091
65525
22819
74253
56090
74128
37327
29704
74114
74186
74202
66302
67577
10202
74081
1724...

result:

ok q=100000

Test #8:

score: 0
Accepted
time: 362ms
memory: 30832kb

input:

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

output:

0
34128
53109
48748
37341
77286
77109
56398
77110
43524
77161
11898
77310
73363
46494
77248
63423
77244
74044
67084
77199
77283
66573
77104
56104
8944
77178
77163
66316
77133
70066
77297
77172
77238
77159
39438
13149
13978
61243
45841
69823
77222
77128
77181
12733
77265
77171
77247
34105
77211
53086...

result:

ok q=100000

Test #9:

score: 0
Accepted
time: 276ms
memory: 18236kb

input:

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

output:

0
0
0
0
0
0
0
0
7808
7531
7510
49211
40367
7793
7807
32933
49196
49210
97417
7620
7567
7613
49023
48970
7751
7717
49016
7822
49154
49120
7710
49225
49113
393
7845
7524
49248
37938
838
1282
1725
2167
7800
7666
7866
49203
49069
49269
2608
7833
7595
7737
7560
7530
7730
7472
7640
7768
7540
49236
48998
7...

result:

ok q=100000

Test #10:

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

input:

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

output:

0
0
0
0
17598
22772
62304
62416
62507
3705
62406
62459
17864
23038
68798
90358
98639
3971
17473
20286
17614
22788
20429
66536
20541
66648
17482
22656
23966
24078
20632
66739
24169
3580
3721
3589
88943
20531
66638
17699
22873
68633
84838
84929
3806
24068
84828
95303
20584
66691
24121
84881
48368
4863...

result:

ok q=100000

Test #11:

score: 0
Accepted
time: 52ms
memory: 8896kb

input:

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

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok q=100000

Test #12:

score: 0
Accepted
time: 290ms
memory: 97940kb

input:

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

output:

5550

result:

ok q=100000

Test #13:

score: 0
Accepted
time: 308ms
memory: 69188kb

input:

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

output:

2491
4245
4681
5116
5550
6846
72250
85298
35965
69865
70350
85210
24045
17296
70108
85295
15666
85276
53151
22875
84286
85204
83935
32350
66615
64266
48151
10680
45555
85217
85240
58183
67885
85283
83401
66100
85225
85149
85222
24820
85278
85267
5983
41541
85286
62655
71545
53455
85209
85292
60451
1...

result:

ok q=100000

Test #14:

score: 0
Accepted
time: 334ms
memory: 47588kb

input:

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

output:

182
64934
64720
17607
35514
64740
64849
64911
60357
39039
64883
64946
29666
64902
25112
49647
64928
47414
24339
64708
64897
64878
64706
64948
64865
42126
26264
25881
64780
18816
64929
59231
64947
15572
63639
64843
64915
64716
64744
64746
10164
42464
64712
64847
64900
64814
4587
64788
627
1071
1514
1...

result:

ok q=100000

Test #15:

score: 0
Accepted
time: 357ms
memory: 28248kb

input:

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

output:

397
842
4366
8681
10801
11642
12896
13312
14141
14554
16196
17417
17822
19432
20231
21026
21422
21817
22604
22996
23387
23777
24166
26479
26861
28001
28756
29132
29507
30254
30626
31367
31736
32104
32471
33929
35012
35371
35729
36086
36797
37151
38557
39601
40292
42341
42679
43016
43687
44021
44686
...

result:

ok q=100000

Test #16:

score: 0
Accepted
time: 271ms
memory: 16532kb

input:

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

output:

52333
52328
52270
52385
52170
50232
20370
32212
52350
52177
42082
9273
52378
52164
29248
52146
52116
52263
24295
10963
52367
52210
52299
52107
30738
52157
52360
52215
52342
52305
52166
52294
48013
51168
5845
52375
17158
52390
38647
52259
9697
15118
38995
52296
52213
52352
43762
52403
52128
39688
521...

result:

ok q=100000

Test #17:

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

input:

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

output:

94959
82564
69203
91583
7778
91709
25279
67958
89144
65131
37103
42968
73249
94980
75274
28331
94433
90539
94986
19784
83653
42631
68956
33881
94948
50129
87181
94994
78263
80669
74384
94983
26431
89288
57679
89573
95007
94929
48544
29084
79484
66944
80278
68708
21769
76793
59681
82193
94996
95000
9...

result:

ok q=100000

Test #18:

score: 0
Accepted
time: 71ms
memory: 8388kb

input:

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

output:

6
7
8
9
10
11
13
14
16
17
19
21
22
23
24
25
28
30
31
36
37
38
39
40
41
43
45
49
52
53
55
57
60
61
66
67
68
69
70
71
72
74
75
77
78
79
81
82
83
84
88
90
91
96
98
100
104
105
107
108
110
111
112
115
116
118
119
120
121
123
127
130
131
135
140
143
144
150
151
156
159
161
163
165
168
169
171
173
179
180...

result:

ok q=100000

Test #19:

score: 0
Accepted
time: 280ms
memory: 98484kb

input:

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

output:

891

result:

ok q=100000

Test #20:

score: 0
Accepted
time: 315ms
memory: 69924kb

input:

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

output:

7257
10661
14826
16464
18891
25956
29367
31227
33426
33789
34512
34872
37011
41181
41522
42539
46517
47489
48132
48452
48771
50037
51597
53739
54642
56127
56421
60152
62091
62636
63177
64247
64776
65301
65822
66339
68367
68864
72231
73157
73614
73841
76272
76914
77337
77756
78171
79392
80964
81347
8...

result:

ok q=100000

Test #21:

score: 0
Accepted
time: 336ms
memory: 45656kb

input:

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

output:

841
22210
25711
42678
64915
69496
78516
89901
95890
97146
97216
98436
98438
98453
98454
33928
28755
14553
71428
77686
48910
24165
98426
97678
43351
82426
58876
81486
31735
40635
88753
72835
4801
79128
91881
98414
36441
83341
89761
53575
84925
48591
87696
92250
68506
75760
95626
93745
85770
77053
133...

result:

ok q=100000

Test #22:

score: 0
Accepted
time: 351ms
memory: 30048kb

input:

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

output:

0
0
29762
29909
29565
29705
29860
29628
29859
15052
29725
29648
11736
29844
29678
29835
29704
29885
29789
29723
29902
29748
29602
29924
29829
27297
29787
29792
29624
85565
95832
29730
29712
29577
29892
29805
29675
29753
29793
29578
29850
29863
29719
29874
29658
2727
29764
29810
29668
29596
29625
288...

result:

ok q=100000

Test #23:

score: 0
Accepted
time: 270ms
memory: 17632kb

input:

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

output:

13998
14093
13930
19221
19289
19384
13801
13852
14040
19092
13891
13875
13866
19143
13997
19331
19182
19166
13789
19328
13782
19100
19201
19350
6171
12544
19159
19084
19402
19308
14049
19339
19190
4885
19171
19206
5319
13786
14071
14039
19400
14036
13958
19281
19423
13375
13840
13943
19411
13921
137...

result:

ok q=100000

Test #24:

score: 0
Accepted
time: 160ms
memory: 10816kb

input:

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

output:

0
0
0
0
87174
17362
10746
74601
78462
3436
59337
17182
10566
59271
69877
17222
10606
69811
59289
69829
3256
3296
31312
31132
31172
67699
59242
61573
17190
87255
87150
17443
56452
17338
17172
9423
51007
87218
9175
17154
17406
40527
87158
17122
87140
56158
17346
17328
28647
87228
17171
17089
17416
658...

result:

ok q=100000

Test #25:

score: 0
Accepted
time: 58ms
memory: 6876kb

input:

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

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok q=100000

Test #26:

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

input:

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

output:

608

result:

ok q=100000

Test #27:

score: 0
Accepted
time: 360ms
memory: 70432kb

input:

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

output:

6149
5956
6058
5921
5792
5867
6078
5768
6147
5741
5294
5743
6022
6153
5812
6085
5786
5975
5896
5826
5879
5809
5947
5895
6006
5996
5794
1787
5882
5754
5951
5934
5910
6075
6146
5977
5988
5914
5987
5900
6041
5876
5749
6115
5948
5961
6014
5998
6039
5854
5815
5728
5808
6008
5959
6027
5861
6100
5847
6159
...

result:

ok q=100000

Test #28:

score: 0
Accepted
time: 365ms
memory: 47288kb

input:

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

output:

23495
23676
2715
23715
4032
23702
23541
16287
23622
23716
23717
23747
23709
23739
23545
23564
23698
23659
23700
5339
23686
22686
22295
23623
23569
23694
23590
23827
23690
23503
23582
23767
23585
3594
23547
23770
23793
23557
23661
23524
23837
23632
23518
23618
23645
23754
23501
946
23811
23558
23583
...

result:

ok q=100000

Test #29:

score: 0
Accepted
time: 366ms
memory: 28820kb

input:

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

output:

67334
35758
67364
35787
43730
67272
67239
1080
51596
32665
67175
67154
67392
67163
60726
26683
67150
67393
67379
67180
67383
12279
59319
67160
11860
67396
58174
67303
67230
67142
29706
67391
67291
67390
67279
67315
9751
33031
47487
67284
67309
67144
67243
67323
33396
24760
18035
67341
67184
27825
67...

result:

ok q=100000

Test #30:

score: 0
Accepted
time: 275ms
memory: 17644kb

input:

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

output:

0
74629
68961
74404
79842
79876
74636
68968
74411
74711
69043
51005
50981
72547
68928
74486
51004
72546
74790
45885
69123
74731
31227
45861
31597
59068
69063
31203
31573
71130
59044
68922
74752
67174
69084
67150
74566
45884
74781
69114
46213
33067
46189
74747
33043
74800
41197
49749
74810
74806
6907...

result:

ok q=100000

Test #31:

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

input:

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

output:

0
0
0
0
0
0
73788
90848
73764
87337
73833
93359
18873
18987
90832
87321
91403
18971
21357
21333
90943
80973
77100
87432
80949
77076
77946
77922
21402
95976
81018
77145
77991
18705
19082
18907
18888
18892
73703
75822
75806
21272
26417
5592
64395
16945
90944
26393
5568
64371
16921
87433
26462
5637
644...

result:

ok q=100000

Test #32:

score: 0
Accepted
time: 52ms
memory: 8932kb

input:

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

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok q=100000

Test #33:

score: 0
Accepted
time: 330ms
memory: 99636kb

input:

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

output:

65140

result:

ok q=100000

Test #34:

score: 0
Accepted
time: 368ms
memory: 69660kb

input:

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

output:

75980
75964
67685
53474
14811
76046
76003
75946
65102
75953
21275
75975
76020
76041
76059
24023
17671
76001
76050
68189
69680
70169
672
69187
31598
76133
75950
76017
46544
44569
76027
76136
76055
75956
76079
76075
17265
76154
66663
75951
57637
9793
72784
76142
18883
55876
56761
76076
62965
76077
704...

result:

ok q=100000

Test #35:

score: 0
Accepted
time: 368ms
memory: 48072kb

input:

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

output:

1850
3173
6219
6650
7937
8791
9642
10489
10910
11330
11750
13420
14660
15483
15892
16300
16707
17113
17518
18326
20727
21519
22307
22700
23483
23873
25035
25421
26187
26570
27710
28089
28466
28843
29218
29969
29970
29971
29980
29984
29985
29988
29989
29990
29991
29995
30000
30006
30007
30011
30012
3...

result:

ok q=100000

Test #36:

score: 0
Accepted
time: 368ms
memory: 29372kb

input:

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

output:

33702
45920
43477
46037
45961
18777
46052
45803
46012
46029
46064
46114
45835
24310
46120
38339
46053
27764
45847
45816
31505
45889
45950
562
45932
45976
45850
46033
17160
45854
46086
46025
45805
45927
46030
41106
45874
4093
17566
45871
46091
45881
46057
45856
45999
23531
45995
45928
46075
45834
458...

result:

ok q=100000

Test #37:

score: 0
Accepted
time: 282ms
memory: 17652kb

input:

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

output:

36812
21931
36841
36601
36874
36766
36582
30360
36556
36828
36563
36688
17938
35472
36776
36595
36722
36894
23109
36876
36808
29238
36810
36851
36693
36793
10926
13019
36586
36699
4936
36562
35113
25440
36704
17128
36611
36844
36573
36625
36824
36580
537
36887
36838
16721
36725
36796
36721
36679
367...

result:

ok q=100000

Test #38:

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

input:

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

output:

505
4029
4902
5336
7063
9624
11729
12565
13398
14639
16279
17905
20313
20711
21108
21504
22293
23077
23857
24246
24635
24636
24640
24642
24647
24648
24651
24652
24653
24654
24655
24657
24658
24660
24662
24663
24665
24666
24670
24672
24676
24679
24682
24684
24685
24686
24687
24688
24689
24690
24692
2...

result:

ok q=100000

Test #39:

score: 0
Accepted
time: 71ms
memory: 6968kb

input:

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

output:

1
4
5
8
11
12
15
16
17
19
20
25
26
27
28
29
30
33
34
36
37
38
40
43
45
47
48
49
51
52
53
56
58
59
60
62
64
66
67
69
71
72
73
75
78
81
82
83
85
86
87
89
90
92
93
95
96
97
98
104
105
106
107
109
110
112
113
115
116
123
125
128
129
135
139
140
141
143
145
146
147
150
152
155
156
160
162
164
165
170
174...

result:

ok q=100000

Test #40:

score: 0
Accepted
time: 292ms
memory: 97880kb

input:

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

output:

78480

result:

ok q=100000

Test #41:

score: 0
Accepted
time: 354ms
memory: 71112kb

input:

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

output:

33652
34044
34048
34073
34075
34082
34091
34121
34158
34161
34167
34173
34203
34204
34218
34220
34232
34235
34240
34241
34243
34244
34245
34246
34261
34262
34264
34269
34271
34274
34275
34279
34280
34282
34283
34285
34288
34294
34299
34301
34303
34304
34308
34321
34324
34325
34329
34333
34337
34340
...

result:

ok q=100000

Test #42:

score: 0
Accepted
time: 356ms
memory: 46492kb

input:

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

output:

0
94012
39587
14090
93951
23344
59469
93915
8630
60876
71009
42671
93797
94009
91649
80219
24902
92278
93926
93686
91259
71488
82153
2998
18583
15328
42332
38540
94011
84341
28724
93959
85718
29101
88130
92999
57746
86053
68805
94006
93965
71961
72197
62534
93955
46657
27587
93993
82713
69794
93995
...

result:

ok q=100000

Test #43:

score: 0
Accepted
time: 369ms
memory: 28196kb

input:

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

output:

0
0
0
0
0
0
0
46498
65177
65211
46689
89498
46666
46629
89475
46589
46554
46573
6266
89438
46453
84990
78352
82106
6448
40059
34049
46643
46746
46711
52322
40404
40241
46623
46687
1010
46499
46692
46658
46741
46754
35129
46648
34230
89452
46484
46463
89555
46512
40585
89432
46669
21557
1192
46713
65...

result:

ok q=100000

Test #44:

score: 0
Accepted
time: 277ms
memory: 17916kb

input:

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

output:

42985
3646
42998
42919
82126
45647
41286
78368
3795
3654
3641
3776
82139
45660
41299
78381
58305
44656
65454
3651
61137
90850
4723
3721
3705
3862
3547
63863
90952
75145
90870
36400
90906
66237
47281
90972
74474
90876
67011
3715
90881
3964
3761
47926
90914
90887
9029
90867
3882
758
79993
3627
3918
37...

result:

ok q=100000

Test #45:

score: 0
Accepted
time: 158ms
memory: 10600kb

input:

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

output:

0
75065
75250
75258
44238
78831
97278
97286
44387
55875
56024
75088
83286
75191
96767
27099
52882
53067
38447
68703
62706
38632
78879
68888
62891
99654
53075
38640
68896
62899
99662
44154
38319
78886
99771
99816
44211
44188
44435
44442
78739
86293
86301
44295
52791
38356
55848
55825
56072
56079
5593...

result:

ok q=100000

Test #46:

score: 0
Accepted
time: 61ms
memory: 8992kb

input:

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

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok q=100000

Test #47:

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

input:

100000 100000
5722 1
35633 1
76503 1
2 8454
2 93428
3 91414
4 55025
21132 5
6 22400
6 80941
7 22043
7 29361
7 73158
78568 7
8 24159
8 26175
27612 9
39375 9
5454 10
24262 10
40601 10
11 8620
59525 11
11 79781
11 92891
64034 12
33728 14
14 59378
14 79826
560 16
16 31445
35262 16
17911 17
28509 17
9364...

output:

14208

result:

ok q=100000

Test #48:

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

input:

100000 100000
32763 1
1 41318
52251 1
66464 2
83572 2
67186 5
7 64990
34545 8
8 96178
8628 9
10 8181
94794 15
16 33467
16 34451
85594 16
17 20413
31799 17
17 41753
18 61787
71853 18
19 5788
19 49136
97968 19
34661 20
20 61751
95244 20
20211 21
31082 21
22 96882
53538 23
53831 24
81268 24
25 52202
61...

output:

39777
48181
83963
83964
48487
48488
48489
48490
13198
42757
79651
79652
61609
69615
75581
22645
23102
30536
30537
30538
9533
27929
27930
27931
13512
13513
13514
75424
94777
86075
86076
86077
68685
95258
95259
40039
66963
94407
1066
8174
53584
53585
55592
55593
49164
85418
60583
46010
67162
67163
807...

result:

ok q=100000

Test #49:

score: 0
Accepted
time: 191ms
memory: 12364kb

input:

100000 100000
98 1
1 39536
2 7197
2 36925
64304 2
3 90981
4 55694
4 58594
6 14112
6 61223
49657 7
49961 8
9 63064
84290 9
9616 10
10 26834
10 81424
11 28592
66665 11
11 67518
12 65671
12 77007
13 83518
88724 13
14 22525
28934 14
38904 15
18454 16
16 34371
33103 17
63576 17
46939 18
67514 18
18 72374...

output:

7911
57822
45527
45528
45529
45530
1993
17940
41483
68910
89804
82406
17512
79123
88547
88548
84279
54951
54952
54846
54847
60553
91003
49382
49383
49384
3764
33414
39193
94693
71136
80887
26126
73009
77086
4708
92039
92784
97838
31730
88652
88653
88654
74286
75030
87343
60207
63805
65818
80204
8366...

result:

ok q=100000

Test #50:

score: 0
Accepted
time: 233ms
memory: 12304kb

input:

100000 100000
1 30554
51310 1
1 71883
94585 1
2 40250
59351 2
2 60517
72989 3
4 3248
14035 4
4 90751
5 786
6 10125
87221 6
22862 7
7 57323
67940 7
40455 8
8 66854
9 34854
9 87440
43694 10
10 57462
82982 10
94968 10
47934 11
11 71829
24007 12
44565 12
48286 12
70260 12
12 70368
98761 12
20547 14
7549...

output:

11901
49549
49550
49551
40431
50261
71477
71478
26532
17118
45418
52035
58649
36518
76838
76839
35164
14555
14556
41475
92807
33488
3268
3269
3270
3271
35452
35453
35454
85164
87811
99176
34109
50164
18489
26073
48037
31354
31355
8106
16879
63000
76203
82770
10949
56894
9191
66650
16052
16897
16898
...

result:

ok q=100000

Test #51:

score: 0
Accepted
time: 196ms
memory: 12448kb

input:

100000 100000
26140 1
46196 2
2 54845
78912 3
3 90871
4 12358
5 33609
5 43410
5 78393
47818 6
7 48862
13216 8
8 36636
8 40979
52931 8
8 80000
94821 8
52306 10
14072 12
36807 12
66342 12
344 13
13 4469
13 14570
13 52573
15 29037
15 38532
86576 15
16 9718
43023 16
16 86523
19 16448
20 15703
20 62471
8...

output:

0
0
0
0
33676
0
0
0
3296
56000
64094
70591
81127
25081
25082
25083
38370
38371
38372
6529
39238
1281
52444
67311
68074
69480
96503
28482
43568
19895
19896
61668
76367
6360
12953
12954
12955
12956
9074
9126
9127
9128
8056
23814
90102
90103
90104
90105
34967
48282
62237
62238
22544
81918
81468
81469
8...

result:

ok q=100000

Test #52:

score: 0
Accepted
time: 133ms
memory: 12280kb

input:

100000 100000
2005 1
1 15170
57799 2
4 38977
4 57240
42542 5
5 53318
5 75678
6 88650
65147 7
8 53626
8 70633
22352 10
11 49862
12 14548
12 50661
12 69416
13 22675
13 57792
3230 14
61629 16
16 94304
19 4752
11292 19
19 23963
47970 19
3280 20
20 13431
37640 20
20 43437
22 59910
69629 22
94875 22
23 52...

output:

0
0
63811
63812
0
0
0
0
0
0
0
0
0
0
0
0
0
64070
0
0
0
0
0
0
0
0
0
0
0
0
0
17930
17931
0
0
0
0
0
0
0
0
0
0
22976
25298
25349
0
46890
63870
79011
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
23473
49655
54550
57471
74503
0
0
0
0
55883
79931
79932
0
0
0
0
0
0
0
0
94320
95578
95579
0
0
72970
93452
0
0
0
0
0
0
...

result:

ok q=100000

Test #53:

score: 0
Accepted
time: 69ms
memory: 10960kb

input:

100000 100000
40394 1
75982 2
3 18844
73366 3
88698 3
4020 6
6 73638
7 22013
65853 7
8 75952
8 91846
8 92431
35947 9
25852 10
60988 10
84698 10
49696 11
60792 11
94447 12
29797 13
14 32289
14 45866
85823 14
15 5953
19579 15
9976 16
16 26641
17 70399
80811 17
18 57277
19 24826
19 72978
15405 20
64474...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok q=100000

Test #54:

score: 0
Accepted
time: 81ms
memory: 12184kb

input:

100000 100000
1 46719
1 85926
2 31507
3 10325
25701 3
4 20660
4 24390
5 28826
5 32895
5 65707
5 85849
26769 6
35848 6
8 31592
9 6175
10 10273
10 49762
8543 11
12 1257
12 49533
67310 12
12 85402
4042 13
13 91901
14 36759
95374 14
40235 16
16 95131
17 47185
49412 17
86267 17
30733 18
19 36525
99630 20...

output:

33627

result:

ok q=100000

Test #55:

score: 0
Accepted
time: 111ms
memory: 12628kb

input:

100000 100000
1 14816
1 36843
1 67254
69974 1
3 22460
4 94861
51245 5
5 53683
54692 6
6 91387
6 91712
8 56288
8 88631
9 4475
23107 9
9 37340
18545 10
10 32507
10 37510
86500 10
57406 11
11 96238
486 12
12 44026
51175 13
14 92685
14 94886
14 99844
66818 15
58293 16
16 92531
17 32186
36963 18
18 53409...

output:

36530
36531
70963
70568
4272
8256
8257
8258
31745
31746
32776
42064
42604
42793
47186
47880
48131
54801
57281
9851
72445
58486
23752
73568
80892
84358
89375
3234
76860
42283
94068
72144
99622
836
1569
1570
1675
1889
7615
9331
1143
10852
11582
11717
12302
12312
12313
13534
6273
14099
15062
15561
1556...

result:

ok q=100000

Test #56:

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

input:

100000 100000
1 92961
32241 2
2 81221
4608 3
16927 3
18769 3
3 43374
22317 4
55044 4
18810 5
6 72739
61007 7
9 25577
9 27864
34366 9
10 16913
30734 10
40980 10
60805 10
74697 10
82279 10
10021 11
23696 12
36468 12
51197 12
86124 12
12 89628
14 6535
14 21742
14 36158
57841 14
15 81216
15 84873
16 457...

output:

14823
14824
64551
75177
85688
50757
50758
5567
46589
77928
48269
42194
88964
97633
74029
1752
4256
4257
4258
5536
6064
6065
6112
6113
8570
9444
9530
9531
10198
10261
11580
11581
5615
13817
14153
14154
14855
14856
15071
15072
15680
15681
15682
15783
15784
16923
16924
17054
17056
17111
17112
19943
199...

result:

ok q=100000

Test #57:

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

input:

100000 100000
1 27333
1 84324
96084 1
9114 2
85952 2
3 5372
4 6733
9091 4
58622 4
4 86657
14441 5
55881 5
77265 5
5 80838
6 348
8 52617
8 61683
11583 9
9 73540
93581 9
94661 9
9 98721
46654 10
10 52226
12 55380
12 79729
13 40841
13 58505
80468 13
57058 14
14 59095
23508 15
68757 15
6286 17
17 39373
...

output:

7739
21429
5108
6105
6484
6485
10804
11252
11253
14811
18997
18998
19172
19173
19174
22325
24037
13992
28772
30278
11371
14257
30899
30900
941
37834
39835
47689
50235
3043
50280
53525
28820
35722
53976
53977
42348
43630
12192
58713
62190
64006
47189
12841
44531
9906
3278
22142
19233
70823
61036
7376...

result:

ok q=100000

Test #58:

score: 0
Accepted
time: 145ms
memory: 12520kb

input:

100000 100000
60818 1
1 61357
77477 1
3 45025
59533 3
46950 4
78991 4
97104 4
36194 5
6 64485
1740 7
5623 8
23553 8
16292 9
62566 9
9 98158
10 23566
10 47129
84382 10
10 89508
11 12522
54918 11
82691 14
89591 14
15 22620
22939 16
56415 16
16 83923
18 29619
18 83502
19 24669
79130 19
43646 20
21 6966...

output:

1813
1814
18850
18851
18853
42125
48045
51189
18228
8761
56832
17388
67745
45626
56412
71375
34895
57374
56127
88897
5002
78624
96309
81492
87323
2141
73142
99266
51021
98591
99347
4500
82214
155
174
175
824
1123
2103
2165
1632
2437
2438
2788
3375
3991
4086
4266
4462
4463
5025
5543
5995
5997
6908
69...

result:

ok q=100000

Test #59:

score: 0
Accepted
time: 109ms
memory: 12636kb

input:

100000 100000
34616 1
58002 1
1 70045
10303 2
2 39631
40632 2
10056 3
41853 3
70173 3
4 92959
5 47483
16468 6
50684 6
67732 6
84535 7
47014 8
59046 9
10 65208
10 78362
11266 11
24545 11
12 21449
66415 12
92002 12
13 19643
13 23316
96267 14
91298 15
17801 16
49544 16
69757 16
4694 17
17 24548
221 18
...

output:

7298
58265
58266
58264
1500
1503
1504
1505
2526
2605
2934
2935
3234
3903
3904
5740
4189
9525
13919
6993
17923
19823
19824
20325
20328
21798
21799
23008
23009
26356
28102
1605
30138
31011
31013
31014
31754
31282
29395
35791
35793
35794
36344
36345
896
36905
36906
38674
38675
38676
38826
38827
18531
3...

result:

ok q=100000

Test #60:

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

input:

100000 100000
1 14279
25034 1
1 25644
1 33907
55554 1
32635 2
48898 2
67742 2
30821 3
62159 3
62878 4
4 99567
5427 5
81073 5
40389 6
68943 6
86783 6
7 7357
8 43901
8 49165
66447 8
15193 10
10 27651
52896 10
11 21927
31071 11
65058 11
1885 12
12 86604
13 34951
13 57211
73415 13
76672 13
31146 14
4934...

output:

1
3
5
9
10
16
17
22
24
32
33
37
42
47
48
50
52
63
64
68
69
70
92
93
100
101
117
120
121
122
131
133
135
136
147
151
164
166
174
177
178
190
191
192
193
197
211
212
215
216
217
218
219
224
225
232
251
253
255
257
258
259
260
264
271
273
280
281
295
296
306
309
310
311
312
315
316
317
319
323
326
327
...

result:

ok q=100000

Test #61:

score: 0
Accepted
time: 81ms
memory: 12176kb

input:

100000 100000
36686 1
2 28317
3 43331
58975 3
9005 5
5 38587
85424 5
87253 5
91242 6
7 12636
7 28747
43112 7
56525 7
95056 7
8 67866
8 96414
15486 9
9 17569
9 27913
9 45216
57385 9
12037 10
10 26847
68194 10
10 69558
91082 10
1181 11
29864 11
11 51315
74564 11
11 99360
50347 12
12 70424
80616 12
810...

output:


result:

ok q=100000

Test #62:

score: 0
Accepted
time: 77ms
memory: 12152kb

input:

100000 100000
19575 1
26203 1
72508 1
1 97963
14667 2
16976 2
3 6175
3 67390
3 85817
3 95274
61098 4
5 63076
48837 6
6 85456
8 11139
8053 9
9 14304
9 42080
78302 9
87001 9
95714 9
10 11640
10 38250
11 68261
33284 12
34067 13
37576 13
13 83578
15 23823
35578 16
57809 16
17 35284
43161 17
17 47477
516...

output:


result:

ok q=100000

Test #63:

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

input:

100000 100000
36059 1
46485 1
23653 2
73424 2
2 74494
51828 3
4 33328
53661 4
34793 5
6 51871
55444 6
6 65656
8 16246
8 34477
10425 9
62445 9
21534 10
10 30313
60761 10
96061 10
7597 11
11 15469
63367 12
40382 13
14 75126
15 56288
15 84929
53927 16
64468 16
17 53139
18 5845
76176 18
19 24677
19 5891...

output:


result:

ok q=100000

Test #64:

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

input:

100000 100000
20177 2
2 98955
3 46743
3 46866
62628 3
12631 4
75181 4
5 54593
27546 6
6 31901
6 83336
6 90688
7 32220
7 63366
8 61776
37721 9
9 48206
9 70008
96585 9
10 62990
98079 10
11 11607
21944 11
11 80964
13 9208
13 49235
13 69968
13 85800
38176 14
57272 14
15 3765
16 67576
17 40546
17 44435
1...

output:


result:

ok q=100000

Test #65:

score: 0
Accepted
time: 75ms
memory: 11740kb

input:

100000 100000
1 33218
2 26924
4 22063
4 72727
83189 4
5 26165
50928 5
6 12110
17480 7
39161 7
7 76692
20436 8
36025 8
9 52297
9 58874
67940 9
10 17168
10 40179
10665 11
11 26766
11 26798
28558 11
41443 11
91932 11
11 96520
12 38384
89050 13
14 44040
14 60933
63286 14
14 91796
38298 15
83369 15
20977...

output:


result:

ok q=100000

Test #66:

score: 0
Accepted
time: 89ms
memory: 11804kb

input:

100000 100000
97038 1
2 12394
73478 2
27345 3
3 52828
3 94198
17649 4
34700 4
4 48092
90308 4
4 92571
5 73178
5 96066
1197 6
79796 6
6 95080
7 6897
7 96564
8 57604
8 70048
29738 10
10 42975
10 99064
11 20156
11 25952
51206 11
11 97949
38714 12
92965 12
10950 13
15 6617
8272 15
17383 15
37580 15
5035...

output:


result:

ok q=100000

Test #67:

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

input:

100000 100000
1 43054
1 66061
45045 4
81759 5
15827 6
6 40801
78430 6
6 83704
3488 9
32237 9
10 8261
10 37635
98555 10
82566 11
30294 12
68894 12
13 32989
92708 14
94972 14
15 41948
16 28327
20490 17
52712 17
18 23230
18 77251
9533 19
66382 19
20 10583
23214 22
32369 22
24 32167
75443 24
26 9052
278...

output:


result:

ok q=100000

Test #68:

score: 0
Accepted
time: 60ms
memory: 13456kb

input:

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

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok q=100000

Test #69:

score: 0
Accepted
time: 67ms
memory: 13296kb

input:

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

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok q=100000

Test #70:

score: -100
Time Limit Exceeded

input:

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

output:


result: