QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#170411#7181. Graph Cutsucup-team952#AC ✓739ms6352kbC++141.3kb2023-09-09 15:12:082023-09-09 15:12:08

詳細信息

Test #1:

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

input:

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

output:

5
4
3
2
0
1
0

result:

ok q=10

Test #2:

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

input:

0 0
0

output:


result:

ok q=0

Test #3:

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

input:

0 0
1
?

output:

0

result:

ok q=1

Test #4:

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

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:

63
62
59
58
56
50
49
48
47
42
40
39
38
33
29
27
25
19
18
16
14
12
10
9
8
5
1
126
125
122
121
120
118
115
114
113
110
109
108
107
106
104
103
101
97
94
91
89
87
84
83
82
81
79
75
73
70
69
67
190
188
186
185
182
181
176
173
171
167
163
160
159
34
157
156
155
154
153
152
174
149
148
147
145
137
105
131...

result:

ok q=100000

Test #5:

score: 0
Accepted
time: 91ms
memory: 6144kb

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:

64

result:

ok q=100000

Test #6:

score: 0
Accepted
time: 253ms
memory: 5560kb

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:

70
44
113
110
103
88
85
172
171
161
43
21
5
176
47
55
46
41
40
53
18
3
37
11
127
126
121
2
128
64
63
62
61
60
59
58
57
54
52
51
50
49
45
39
48
38
36
35
34
33
32
31
30
29
27
26
25
24
20
19
17
15
28
12
10
9
8
7
4
1
125
123
122
120
118
117
112
111
109
106
105
14
119
102
100
98
96
42
95
93
92
90
86
83
8...

result:

ok q=100000

Test #7:

score: 0
Accepted
time: 479ms
memory: 5364kb

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:

180
25
1
107
101
91
186
61
57
54
13
93
78
72
40
23
124
37
126
103
71
189
188
185
175
168
160
154
151
8
150
102
68
158
34
118
94
77
145
159
139
106
128
26
172
162
62
90
21
184
7
20
120
138
92
82
112
33
59
192
191
181
174
173
152
144
130
161
253
242
137
239
237
45
89
166
35
163
127
153
142
250
244
236...

result:

ok q=100000

Test #8:

score: 0
Accepted
time: 642ms
memory: 6032kb

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
127
93
27
111
120
84
191
20
189
177
152
151
141
241
240
235
220
217
309
188
294
292
264
203
303
290
379
375
30
32
99
369
330
118
169
202
312
259
320
353
441
428
29
302
378
417
414
396
342
477
156
286
475
47
185
64
63
62
61
60
59
58
57
56
55
54
52
51
50
49
48
46
45
44
43
42
41
40
39
38
37
36
35
34
...

result:

ok q=100000

Test #9:

score: 0
Accepted
time: 571ms
memory: 6192kb

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
102
81
379
547
526
364
378
824
823
809
991
191
184
138
636
629
288
322
583
393
767
733
281
726
838
970
416
95
540
861
984
1080
1073
1027
371
237
437
682
816
882
1126
166
308
43
101
131
211
111
301
339
404
488
576
310
255
556
546
611
700
90
436
535
267
656
258
703
755
753
746
319
764
...

result:

ok q=100000

Test #10:

score: 0
Accepted
time: 353ms
memory: 5560kb

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
173
618
1062
1505
1947
2388
2828
3267
439
884
1328
1771
2213
2654
48
493
189
634
937
1078
1380
1521
57
502
946
1389
1831
1822
1963
2272
2263
2404
2712
2703
2844
274
719
1163
1606
2048
2489
2929
3094
3151
3142
3283
3368
3580
3533
3589
3705
3721
3806
4026
4017
3971
4158
261
706
376
821
121
202...

result:

ok q=100000

Test #11:

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

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: 92ms
memory: 4980kb

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:

64

result:

ok q=100000

Test #13:

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

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:

64
63
61
58
53
52
50
43
41
39
35
45
33
31
42
25
23
21
20
17
16
62
60
59
57
56
55
54
51
49
48
47
46
44
40
38
37
36
34
32
30
29
28
26
24
18
14
13
10
9
8
5
126
125
123
122
118
114
109
105
104
103
101
100
27
95
93
90
86
84
7
120
96
81
75
74
98
19
11
102
92
112
72
71
66
189
187
185
184
68
22
182
180
110
...

result:

ok q=100000

Test #14:

score: 0
Accepted
time: 481ms
memory: 5404kb

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:

63
62
60
58
52
49
48
47
45
44
42
41
40
39
38
36
32
31
30
27
23
20
22
17
14
12
10
5
128
29
123
120
43
50
16
119
116
115
114
113
110
25
109
108
107
106
103
102
100
98
95
94
92
88
87
86
85
82
81
80
76
71
96
70
67
66
84
190
189
188
187
184
182
180
178
172
169
166
165
164
163
11
162
158
171
154
153
152
1...

result:

ok q=100000

Test #15:

score: 0
Accepted
time: 648ms
memory: 5920kb

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:

62
61
60
59
58
52
48
46
44
43
42
39
38
36
35
34
31
28
27
25
23
22
21
20
18
17
16
15
14
13
12
11
10
8
7
6
4
3
2
127
122
119
117
115
113
110
106
105
104
103
102
40
50
100
98
97
95
94
93
91
90
86
85
84
125
82
81
80
75
73
118
72
68
66
65
192
53
191
26
186
185
183
182
180
178
174
173
172
169
168
1
167
16...

result:

ok q=100000

Test #16:

score: 0
Accepted
time: 578ms
memory: 5560kb

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:

64
63
62
61
60
57
53
51
49
47
46
45
43
42
41
39
38
36
34
33
32
31
30
29
27
26
23
20
19
16
15
12
11
7
6
3
1
128
127
13
126
124
120
119
116
115
114
109
104
103
101
99
94
89
88
87
84
83
82
81
80
78
76
70
69
68
192
191
188
187
186
182
180
179
178
176
175
173
170
169
166
164
161
160
158
157
156
24
155
15...

result:

ok q=100000

Test #17:

score: 0
Accepted
time: 346ms
memory: 5460kb

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:

64
61
58
57
56
52
50
48
42
41
39
38
37
36
34
28
26
24
23
22
20
19
16
14
11
10
9
8
7
6
5
3
2
1
124
122
120
117
116
114
113
112
104
103
101
100
98
96
93
91
88
86
85
84
80
77
75
74
73
72
69
66
65
192
191
189
184
182
180
177
176
174
172
171
170
167
165
162
160
155
154
149
148
146
145
143
142
141
138
136...

result:

ok q=100000

Test #18:

score: 0
Accepted
time: 118ms
memory: 4812kb

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:

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

result:

ok q=100000

Test #19:

score: 0
Accepted
time: 86ms
memory: 4956kb

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:

62

result:

ok q=100000

Test #20:

score: 0
Accepted
time: 265ms
memory: 5400kb

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:

63
62
44
38
34
43
24
32
57
61
16
1
127
125
64
39
123
10
126
120
22
40
55
49
46
18
121
108
105
104
51
41
6
20
12
102
92
56
52
28
59
26
21
4
109
86
84
83
81
76
72
71
69
68
107
66
8
188
47
75
186
42
184
5
53
182
180
3
111
13
181
35
31
54
99
95
50
85
190
176
17
174
172
82
166
161
48
30
25
77
185
183
187...

result:

ok q=100000

Test #21:

score: 0
Accepted
time: 476ms
memory: 5464kb

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:

52
61
1
108
83
69
182
33
240
200
208
236
57
127
110
10
102
90
126
77
43
160
142
30
21
13
155
255
243
234
158
233
59
37
119
256
62
48
186
246
22
18
116
192
180
179
118
28
20
107
176
93
148
143
141
138
254
24
132
85
235
172
232
231
227
147
242
215
128
214
146
201
196
27
194
320
319
313
99
223
310
306
...

result:

ok q=100000

Test #22:

score: 0
Accepted
time: 669ms
memory: 5376kb

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
81
144
221
35
278
376
241
164
27
220
239
194
305
264
118
66
303
308
375
360
351
345
440
425
418
401
140
511
480
246
93
94
191
228
6
174
235
309
127
269
379
89
366
336
72
162
311
358
199
274
361
321
7
65
435
42
124
102
417
410
408
399
390
510
22
487
48
320
161
223
37
252
244
120
222
70
69
215
9
2...

result:

ok q=100000

Test #23:

score: 0
Accepted
time: 571ms
memory: 5368kb

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:

254
186
349
631
699
794
57
108
296
502
147
122
131
576
253
567
553
592
45
490
38
483
698
741
14
459
946
934
927
903
305
750
1020
1011
997
1075
1036
42
295
327
487
214
292
659
740
737
96
199
541
54
177
420
499
622
644
285
168
380
143
364
416
613
588
730
825
809
370
401
815
772
865
861
846
943
931
153...

result:

ok q=100000

Test #24:

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

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
342
787
1231
1674
2116
2557
162
607
1051
1494
202
647
1091
1534
1976
1936
2417
2377
2857
2817
2997
3256
3296
170
615
423
318
763
152
597
868
21
134
386
466
579
831
102
326
547
308
151
596
753
69
396
514
771
841
186
631
15
460
360
805
958
395
840
910
904
106
87
111
556
551
532
443
888
1023
10...

result:

ok q=100000

Test #25:

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

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: 92ms
memory: 5016kb

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:

64

result:

ok q=100000

Test #27:

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

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:

242
78
207
54
29
40
27
35
12
4
23
22
14
19
49
11
116
3
123
112
28
17
26
10
1
52
43
59
48
30
25
21
15
120
111
109
108
107
101
99
98
95
94
56
24
50
85
46
44
42
124
105
84
75
70
66
65
55
190
188
104
186
91
82
6
185
51
7
113
100
96
128
121
13
117
88
83
61
79
192
127
87
187
81
41
89
76
184
110
182
169
86...

result:

ok q=100000

Test #28:

score: 0
Accepted
time: 483ms
memory: 5396kb

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:

9
6
83
38
129
304
210
291
264
305
306
337
153
54
53
12
8
91
112
106
179
2
89
13
172
171
158
17
3
174
164
149
58
21
116
105
85
110
147
146
136
135
102
142
43
133
130
249
247
245
240
117
104
239
100
233
90
230
220
42
123
27
131
219
84
175
124
34
96
81
64
63
62
61
59
57
56
55
52
51
50
49
47
46
45
44
41...

result:

ok q=100000

Test #29:

score: 0
Accepted
time: 649ms
memory: 5392kb

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:

383
829
413
859
1274
2
288
64
80
166
136
224
212
229
204
28
27
161
157
209
72
192
22
123
81
200
279
364
358
194
352
340
333
292
328
59
82
372
42
321
446
445
442
441
440
439
432
67
233
428
218
55
141
283
32
63
196
354
327
425
390
511
508
163
263
261
430
400
507
370
165
503
499
476
472
471
466
567
58
...

result:

ok q=100000

Test #30:

score: 0
Accepted
time: 589ms
memory: 5396kb

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
246
692
1137
1581
2023
253
699
1144
328
774
134
580
213
659
1025
1104
1219
408
118
564
348
76
522
77
161
523
607
794
207
653
854
191
369
637
815
1009
968
399
845
119
81
565
364
527
104
130
428
424
418
576
810
874
870
126
10
239
215
456
79
154
423
286
31
133
477
572
525
600
579
270
685
661
732
716
...

result:

ok q=100000

Test #31:

score: 0
Accepted
time: 361ms
memory: 5340kb

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
218
332
663
777
1108
1222
1552
1666
316
761
1206
1650
50
495
252
233
426
697
678
872
237
682
940
1142
1127
1123
1317
1384
1586
1571
1567
1761
1827
2029
2014
2010
63
39
12
180
427
508
484
457
625
873
953
929
902
1070
1318
1397
1373
1346
238
683
73
518
963
1128
1407
1514
1572
1789
1762
185...

result:

ok q=100000

Test #32:

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

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: 89ms
memory: 5072kb

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:

63

result:

ok q=100000

Test #34:

score: 0
Accepted
time: 265ms
memory: 5400kb

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:

64
63
60
58
57
54
52
62
61
59
56
55
53
51
49
48
46
45
42
47
39
38
37
36
35
34
33
31
29
27
25
24
23
21
20
17
16
26
15
14
12
10
9
8
19
7
6
5
4
3
2
126
125
124
119
118
115
113
111
11
110
109
50
44
43
41
32
30
28
22
13
1
127
128
123
122
121
117
120
116
114
105
102
101
100
99
96
95
94
93
103
91
90
89
88
...

result:

ok q=100000

Test #35:

score: 0
Accepted
time: 483ms
memory: 5524kb

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:

64
63
62
61
60
57
56
54
53
51
50
49
43
41
40
39
38
37
36
34
31
27
26
25
24
22
18
15
14
52
7
5
125
124
122
119
118
117
114
113
112
13
106
101
97
96
95
94
91
90
86
77
76
75
71
70
69
67
16
47
188
185
184
182
9
181
45
23
19
183
165
162
109
161
160
21
17
6
104
157
12
116
89
66
174
149
148
147
146
173
143...

result:

ok q=100000

Test #36:

score: 0
Accepted
time: 647ms
memory: 5400kb

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:

64
60
59
57
55
52
51
49
48
46
43
36
34
32
30
29
28
26
25
23
21
18
17
15
35
14
12
7
6
5
4
3
2
128
125
123
122
120
119
118
114
113
112
110
109
107
105
20
16
103
102
33
101
98
97
95
94
91
90
89
87
85
84
117
82
81
78
74
72
115
71
68
66
192
187
184
181
180
178
174
172
167
166
165
164
163
162
161
22
104
1...

result:

ok q=100000

Test #37:

score: 0
Accepted
time: 576ms
memory: 5372kb

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:

60
58
56
53
51
50
48
47
46
44
41
36
35
34
33
32
29
27
43
24
23
21
26
45
20
17
15
14
13
12
62
9
7
5
4
3
126
125
123
120
119
115
112
109
106
105
100
99
97
93
91
85
83
82
81
79
72
69
65
191
190
189
80
188
186
185
49
184
183
179
178
177
175
174
168
66
166
165
162
155
152
151
150
148
147
145
142
141
140
...

result:

ok q=100000

Test #38:

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

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:

61
60
58
57
55
53
51
50
49
48
42
38
34
31
29
27
22
16
12
11
9
1
127
126
30
125
120
119
117
115
114
113
112
111
110
109
107
104
101
97
95
91
90
88
87
85
83
82
81
80
79
78
77
76
73
72
65
191
190
188
187
186
3
185
184
180
178
176
175
174
173
171
118
169
168
163
162
160
159
158
156
155
154
153
151
149
1...

result:

ok q=100000

Test #39:

score: 0
Accepted
time: 114ms
memory: 4760kb

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:

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

result:

ok q=100000

Test #40:

score: 0
Accepted
time: 92ms
memory: 5172kb

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:

63

result:

ok q=100000

Test #41:

score: 0
Accepted
time: 246ms
memory: 5576kb

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:

83
50
61
45
36
38
26
19
5
56
25
3
113
35
118
105
81
71
66
9
123
43
111
97
74
22
46
11
117
8
104
91
47
24
7
128
29
32
18
126
12
20
58
1
100
94
87
79
86
23
70
192
190
188
186
179
51
116
67
53
15
13
176
175
180
62
34
185
191
28
108
63
124
93
174
173
169
167
59
95
64
92
69
48
171
170
68
166
165
164
55
1...

result:

ok q=100000

Test #42:

score: 0
Accepted
time: 494ms
memory: 5932kb

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
32
55
19
108
99
59
167
162
248
6
102
116
82
70
190
208
206
141
118
318
315
300
294
114
25
27
176
131
8
166
239
101
80
240
235
106
231
127
150
244
224
52
304
207
211
293
291
126
21
38
180
154
312
290
286
273
314
168
276
270
233
258
383
374
189
368
362
223
221
210
285
227
142
121
194
62
44
26
22
13
...

result:

ok q=100000

Test #43:

score: 0
Accepted
time: 644ms
memory: 5396kb

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
183
629
1073
374
820
314
351
760
239
274
14
258
460
138
584
704
685
797
101
84
328
431
396
547
102
548
2
184
308
377
372
87
343
333
448
439
426
533
169
148
530
197
630
615
51
354
497
398
594
357
205
154
115
59
75
117
133
196
261
124
1
104
237
303
403
446
217
440
512
125
212
511
510
509...

result:

ok q=100000

Test #44:

score: 0
Accepted
time: 581ms
memory: 5460kb

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:

109
555
1000
1443
258
117
104
239
563
550
704
685
1008
995
1148
1129
114
184
560
630
10
168
325
456
614
771
901
178
224
345
90
427
187
122
381
221
190
351
447
568
356
536
636
124
362
389
20
342
466
1
247
448
512
511
510
76
253
302
509
508
292
507
506
505
504
503
502
501
500
499
498
497
496
26
166
49...

result:

ok q=100000

Test #45:

score: 0
Accepted
time: 371ms
memory: 5344kb

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
223
667
1112
1554
370
816
1261
1703
1997
2146
2439
2587
2878
3027
3318
140
583
96
174
197
539
418
640
617
864
984
1085
1062
1028
1309
1470
1426
425
871
1316
1527
1504
1758
1751
278
724
1169
1611
1913
1869
1970
1947
2054
2201
2194
2355
2311
2412
2389
2496
2642
436
882
1327
1769
2212
2653
2635
2751
...

result:

ok q=100000

Test #46:

score: 0
Accepted
time: 114ms
memory: 4808kb

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: 157ms
memory: 5784kb

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:

63

result:

ok q=100000

Test #48:

score: 0
Accepted
time: 314ms
memory: 6140kb

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
13198
22645
9533
1066
8174
12375
13514
13513
13512
12728
16155
17100
21768
21767
5804
13990
13989
19765
8756
19557
21766
12032
13252
4930
13522
189
1845
1844
8750
5177
5176
9930
15207
10158
5805
13628
1084
2924
4460
8664
12306
14893
15971
541
540
539
901
900
5293
8920
14147
15034
8609
21...

result:

ok q=100000

Test #49:

score: 0
Accepted
time: 545ms
memory: 6176kb

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:

1993
3764
4708
7911
254
253
252
251
250
249
4317
4316
6849
10918
8020
8019
8018
12013
15691
15690
10169
15689
15688
10188
2538
4302
16068
16067
16066
5000
16065
17512
17940
20986
21537
3597
21789
12992
20396
20745
10520
12160
22718
14247
23223
23553
23848
6715
6714
15719
15718
2198
16596
23847
24130...

result:

ok q=100000

Test #50:

score: 0
Accepted
time: 739ms
memory: 6148kb

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
40431
49551
49550
49549
50261
26532
17118
45418
36518
35164
14556
3271
3270
3269
3268
14555
33488
8106
10949
9191
16879
18489
26073
31355
31354
34109
35454
18538
35453
35452
41209
41475
3678
48037
22738
22737
21390
29370
33368
33367
50164
25349
50660
52035
56894
14848
55161
13232
12467
16052
1...

result:

ok q=100000

Test #51:

score: 0
Accepted
time: 712ms
memory: 6144kb

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
25083
25082
25081
38372
38371
6529
19896
19895
28482
38370
39238
1281
6360
12956
9074
9128
9127
9126
12955
12954
12953
43568
52444
8056
22544
23814
13771
28457
14145
34967
48282
61668
62238
62237
845
64094
11407
35692
40004
59096
67311
67816
68074
69480
70591
76367
811...

result:

ok q=100000

Test #52:

score: 0
Accepted
time: 487ms
memory: 6140kb

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
63812
63811
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
17931
17930
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
79932
79931
0
0
0
0
0
0
0
0
94320
95579
95578
0
0
72970
93452
0
0
0
0
0
0
...

result:

ok q=100000

Test #53:

score: 0
Accepted
time: 126ms
memory: 5460kb

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: 146ms
memory: 5916kb

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:

64

result:

ok q=100000

Test #55:

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

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:

64
63
57
56
55
52
50
49
48
46
45
44
41
40
39
38
37
36
33
32
30
27
24
16
15
14
13
10
9
8
7
6
4
3
2
1
127
126
124
120
119
117
113
112
110
108
105
104
101
99
98
94
92
91
89
88
87
83
82
81
80
79
77
76
75
71
67
65
192
189
188
187
183
182
181
180
177
174
172
170
166
164
162
160
159
154
153
151
150
149
148...

result:

ok q=100000

Test #56:

score: 0
Accepted
time: 291ms
memory: 6044kb

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:

60
57
54
52
51
50
49
48
43
42
38
37
36
33
32
31
30
29
28
27
26
25
22
18
12
11
10
8
6
5
4
3
128
125
123
122
121
119
117
115
114
113
112
111
109
108
106
103
102
100
98
97
95
93
92
91
86
82
81
79
77
74
72
70
69
68
67
65
192
190
189
188
185
183
182
180
179
177
175
174
172
171
169
168
167
165
164
163
162...

result:

ok q=100000

Test #57:

score: 0
Accepted
time: 375ms
memory: 6236kb

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:

57
55
54
49
48
46
45
44
41
40
37
34
33
32
30
28
26
25
24
23
22
21
20
17
16
13
12
11
9
6
5
2
1
127
126
124
123
122
121
119
118
115
114
113
112
111
109
108
107
106
105
104
102
101
96
94
93
92
89
88
87
84
83
79
78
75
74
73
72
71
70
69
65
191
190
189
182
180
178
175
173
172
170
167
165
163
161
159
158
1...

result:

ok q=100000

Test #58:

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

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:

62
60
59
58
57
56
55
50
49
48
47
44
43
40
39
38
37
36
34
32
30
27
26
25
24
23
21
18
15
14
13
10
8
3
127
125
124
123
119
117
116
115
113
112
110
109
106
104
100
98
97
94
91
90
88
87
82
78
76
74
73
72
70
68
67
66
65
189
187
186
184
181
178
175
174
171
170
169
166
164
163
162
159
155
154
153
151
150
14...

result:

ok q=100000

Test #59:

score: 0
Accepted
time: 240ms
memory: 6348kb

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:

63
60
59
57
55
54
53
52
48
47
46
42
41
40
30
29
26
25
21
19
15
14
126
123
120
119
118
116
115
112
109
105
102
101
100
96
95
94
91
89
88
86
84
82
81
79
76
74
73
71
189
188
187
184
183
178
177
176
175
172
170
169
168
167
165
164
161
160
157
156
154
153
152
145
144
141
140
138
137
129
254
252
247
246
2...

result:

ok q=100000

Test #60:

score: 0
Accepted
time: 147ms
memory: 5860kb

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:

64
63
61
57
56
52
50
48
47
46
45
44
42
40
37
36
33
32
27
26
25
24
22
20
17
16
10
9
5
3
1
128
126
125
124
122
121
120
117
109
107
106
105
104
101
100
93
92
89
88
86
82
80
79
76
75
73
72
71
70
69
68
67
192
191
190
187
186
185
182
181
178
177
174
173
171
168
166
164
159
157
156
155
154
151
147
145
144
...

result:

ok q=100000

Test #61:

score: 0
Accepted
time: 138ms
memory: 6040kb

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: 162ms
memory: 5656kb

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: 156ms
memory: 5624kb

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: 150ms
memory: 5608kb

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: 155ms
memory: 5652kb

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: 146ms
memory: 5660kb

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: 176ms
memory: 5716kb

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: 136ms
memory: 5992kb

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: 141ms
memory: 5600kb

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: 0
Accepted
time: 142ms
memory: 6164kb

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:

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

result:

ok q=100000

Test #71:

score: 0
Accepted
time: 534ms
memory: 6344kb

input:

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

output:

0
64
63
62
61
0
60
0
0
0
59
58
57
0
0
56
0
55
54
53
52
0
51
0
50
0
49
0
0
48
0
47
0
0
46
0
0
45
44
43
0
0
42
0
0
41
0
40
0
0
0
39
38
0
0
0
37
0
0
36
0
0
0
35
0
0
0
34
0
33
32
0
0
0
31
0
30
0
0
0
29
0
0
0
0
28
0
27
0
26
0
0
0
0
0
25
24
23
0
0
0
22
21
0
0
20
19
18
17
16
0
15
14
0
0
0
0
13
0
0
12
0
11
...

result:

ok q=100000

Test #72:

score: 0
Accepted
time: 140ms
memory: 5392kb

input:

99970 100000
2 1
1 3
5 1
7 1
9 1
1 11
13 1
15 1
1 17
1 19
1 21
1 23
1 25
27 1
1 29
31 1
1 33
1 35
37 1
1 39
1 41
1 43
45 1
47 1
1 49
51 1
1 53
55 1
57 1
59 1
1 61
63 1
65 1
1 67
69 1
71 1
73 1
75 1
77 1
79 1
81 1
1 83
85 1
1 87
1 89
91 1
1 93
1 95
1 97
99 1
1 101
1 103
1 105
107 1
109 1
111 1
1 113
...

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 #73:

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

input:

99970 100000
2 1
3 1
5 1
7 1
1 9
1 11
1 13
15 1
1 17
19 1
21 1
23 1
1 25
27 1
29 1
1 31
33 1
1 35
37 1
1 39
1 41
1 43
45 1
47 1
1 49
1 51
53 1
1 55
1 57
59 1
61 1
63 1
65 1
67 1
69 1
1 71
73 1
1 75
1 77
79 1
1 81
1 83
85 1
1 87
89 1
91 1
1 93
1 95
97 1
99 1
1 101
103 1
1 105
1 107
1 109
1 111
113 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 #74:

score: 0
Accepted
time: 328ms
memory: 6116kb

input:

99970 100000
2 1
3 1
5 1
7 1
9 1
11 1
1 13
1 15
1 17
19 1
1 21
1 23
1 25
1 27
1 29
1 31
1 33
1 35
37 1
39 1
1 41
1 43
1 45
47 1
1 49
51 1
1 53
55 1
57 1
59 1
1 61
63 1
1 65
1 67
1 69
1 71
73 1
75 1
77 1
1 79
1 81
1 83
1 85
1 87
89 1
91 1
93 1
1 95
1 97
1 99
101 1
103 1
1 105
1 107
1 109
111 1
1 113
...

output:

1
64
63
62
50048
0
50047
61
60
59
50046
0
58
0
57
56
50045
0
50044
0
55
54
50043
0
50042
53
50041
52
50040
51
50
49
48
47
50039
46
45
44
43
0
42
41
50038
40
50037
0
50036
39
50035
0
38
37
36
0
35
0
50034
0
50033
0
50032
34
33
32
31
30
50031
0
29
0
28
27
50030
0
50029
26
25
24
23
22
50028
0
50027
21
...

result:

ok q=100000

Test #75:

score: 0
Accepted
time: 649ms
memory: 6148kb

input:

99970 100000
2 1
3 1
5 1
7 1
1 9
11 1
13 1
1 15
1 17
1 19
21 1
1 23
25 1
27 1
1 29
1 31
1 33
1 35
37 1
1 39
41 1
43 1
1 45
1 47
1 49
51 1
53 1
1 55
1 57
59 1
1 61
63 1
65 1
1 67
69 1
1 71
73 1
75 1
77 1
79 1
81 1
83 1
85 1
87 1
89 1
91 1
93 1
95 1
1 97
99 1
101 1
103 1
1 105
1 107
1 109
1 111
113 1
...

output:

0
0
0
1
50048
50047
50046
50045
50044
50043
0
64
0
0
50042
50041
63
62
0
0
0
0
0
0
61
60
59
58
57
56
55
50040
54
53
52
51
50039
50038
50037
50036
50035
0
50034
0
0
0
0
50033
0
50
49
48
47
50032
46
45
50031
50030
50029
44
43
42
41
40
39
38
37
36
0
0
35
34
33
32
50028
31
30
29
50027
0
50026
50025
5002...

result:

ok q=100000

Test #76:

score: 0
Accepted
time: 142ms
memory: 6008kb

input:

99970 100000
1 2
3 1
4 1
1 7
1 10
1 13
16 1
19 1
1 22
25 1
1 28
1 31
34 1
1 37
40 1
1 43
1 46
1 49
52 1
1 55
1 58
61 1
64 1
1 67
70 1
73 1
76 1
1 79
82 1
1 85
88 1
1 91
1 94
97 1
100 1
1 103
106 1
109 1
112 1
115 1
118 1
1 121
124 1
1 127
130 1
1 133
1 136
139 1
1 142
1 145
1 148
1 151
1 154
1 157
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 #77:

score: 0
Accepted
time: 147ms
memory: 5604kb

input:

99970 100000
3 1
1 4
1 7
1 10
1 13
16 1
1 19
1 22
1 25
1 28
1 31
34 1
1 37
40 1
43 1
46 1
1 49
1 52
1 55
58 1
1 61
64 1
67 1
70 1
1 73
1 76
79 1
1 82
85 1
1 88
91 1
94 1
1 97
1 100
1 103
106 1
109 1
1 112
115 1
1 118
121 1
1 124
127 1
130 1
1 133
136 1
139 1
142 1
1 145
1 148
151 1
1 154
157 1
1 160...

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 #78:

score: 0
Accepted
time: 304ms
memory: 6168kb

input:

99970 100000
3 1
1 4
1 7
1 10
1 13
16 1
19 1
22 1
25 1
1 28
1 31
1 34
1 37
1 40
1 43
46 1
49 1
1 52
55 1
1 58
1 61
1 64
67 1
70 1
1 73
76 1
1 79
1 82
1 85
88 1
1 91
94 1
97 1
100 1
1 103
1 106
1 109
1 112
1 115
118 1
121 1
1 124
127 1
130 1
1 133
1 136
139 1
142 1
145 1
148 1
1 151
154 1
1 157
1 160...

output:

64
0
1
63
33325
0
33344
33343
33342
62
33341
61
33340
33339
33338
0
60
59
58
57
56
33337
55
33336
54
53
33335
52
33334
51
33333
50
49
48
47
46
45
33332
33331
44
33330
33329
43
42
41
40
33328
33327
39
38
37
36
66688
33326
66687
33408
66686
33407
33406
33405
35
34
33
0
33404
0
32
31
30
33403
66685
0
6...

result:

ok q=100000

Test #79:

score: 0
Accepted
time: 627ms
memory: 6148kb

input:

99970 100000
1 2
3 1
4 1
7 1
1 10
1 13
16 1
1 19
22 1
25 1
1 28
1 31
1 34
1 37
40 1
1 43
1 46
1 49
1 52
55 1
1 58
61 1
64 1
67 1
70 1
1 73
76 1
79 1
82 1
85 1
88 1
91 1
94 1
1 97
1 100
103 1
106 1
109 1
1 112
115 1
1 118
1 121
124 1
127 1
130 1
1 133
136 1
1 139
1 142
1 145
1 148
151 1
154 1
1 157
1...

output:

64
63
62
61
0
0
0
0
0
0
60
59
0
0
0
0
0
0
0
1
58
57
56
55
54
53
52
33344
2
33343
33342
33341
51
50
49
48
47
46
45
44
43
42
33340
33339
33338
41
40
39
38
37
36
35
34
33
32
31
30
29
28
27
26
25
0
0
24
23
22
21
20
0
33337
0
66688
0
0
33336
33335
33334
33333
33332
33331
33330
33329
33328
19
33327
18
17
...

result:

ok q=100000

Test #80:

score: 0
Accepted
time: 141ms
memory: 6176kb

input:

99970 100000
1 2
1 4
5 1
9 1
13 1
1 17
21 1
1 25
1 29
33 1
1 37
41 1
45 1
1 49
1 53
1 57
1 61
65 1
1 69
1 73
1 77
81 1
85 1
89 1
1 93
97 1
101 1
105 1
109 1
113 1
1 117
121 1
1 125
1 129
133 1
137 1
141 1
1 145
149 1
1 153
157 1
161 1
165 1
1 169
1 173
177 1
181 1
185 1
189 1
193 1
1 197
1 201
1 205...

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 #81:

score: 0
Accepted
time: 138ms
memory: 5856kb

input:

99970 100000
1 2
1 4
5 1
9 1
13 1
17 1
21 1
1 25
1 29
1 33
37 1
1 41
1 45
1 49
53 1
1 57
1 61
1 65
1 69
73 1
77 1
81 1
1 85
89 1
93 1
97 1
101 1
105 1
1 109
1 113
1 117
121 1
1 125
129 1
133 1
137 1
141 1
145 1
1 149
1 153
1 157
1 161
1 165
169 1
173 1
177 1
181 1
185 1
1 189
1 193
1 197
201 1
1 205...

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 #82:

score: 0
Accepted
time: 247ms
memory: 6140kb

input:

99970 100000
4 1
1 5
9 1
1 13
17 1
1 21
25 1
29 1
33 1
37 1
41 1
1 45
1 49
53 1
57 1
61 1
1 65
69 1
1 73
77 1
1 81
85 1
89 1
1 93
1 97
1 101
105 1
109 1
113 1
1 117
121 1
1 125
129 1
133 1
1 137
141 1
145 1
149 1
153 1
1 157
161 1
165 1
1 169
1 173
1 177
181 1
185 1
189 1
193 1
1 197
201 1
205 1
209...

output:

25024
64
63
1
24995
0
24994
0
62
61
75008
0
60
59
58
0
57
56
55
54
53
50048
75007
0
50047
25023
50046
0
25022
25021
25020
25019
75006
0
52
51
50
49
48
47
46
50045
50044
50043
50042
0
50041
45
44
43
42
41
25018
25017
50040
40
39
25016
25015
38
37
36
35
34
33
32
31
30
29
25014
28
27
26
25
24
23
22
250...

result:

ok q=100000

Test #83:

score: 0
Accepted
time: 582ms
memory: 6144kb

input:

99970 100000
4 1
5 1
1 9
13 1
17 1
21 1
25 1
29 1
33 1
37 1
41 1
45 1
1 49
53 1
1 57
61 1
65 1
69 1
1 73
1 77
1 81
85 1
1 89
93 1
97 1
1 101
1 105
1 109
1 113
117 1
121 1
1 125
1 129
1 133
1 137
1 141
1 145
1 149
153 1
157 1
1 161
165 1
169 1
1 173
1 177
181 1
1 185
189 1
1 193
1 197
1 201
205 1
1 2...

output:

1
64
49987
25024
25023
75008
0
0
63
62
0
24994
50048
61
60
59
25022
25021
25020
25019
25018
50047
50046
58
57
56
55
54
53
52
51
50
25017
25016
25015
25014
25013
25012
25011
49
25010
25009
48
47
46
45
44
25008
25007
25006
25005
25004
25003
50045
50044
50043
43
42
50042
50041
41
40
50040
50039
39
38
3...

result:

ok q=100000

Test #84:

score: 0
Accepted
time: 154ms
memory: 5588kb

input:

99970 100000
1 2
4 1
6 1
11 1
1 16
21 1
26 1
31 1
36 1
1 41
46 1
1 51
56 1
61 1
66 1
1 71
1 76
81 1
86 1
1 91
96 1
101 1
106 1
111 1
1 116
121 1
126 1
1 131
136 1
1 141
1 146
1 151
1 156
1 161
1 166
171 1
176 1
181 1
186 1
1 191
1 196
1 201
206 1
211 1
216 1
221 1
226 1
1 231
1 236
241 1
246 1
251 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 #85:

score: 0
Accepted
time: 141ms
memory: 5636kb

input:

99970 100000
1 2
3 1
6 1
1 11
1 16
21 1
1 26
1 31
1 36
1 41
46 1
1 51
56 1
61 1
1 66
1 71
76 1
1 81
86 1
91 1
1 96
1 101
1 106
111 1
1 116
121 1
126 1
131 1
136 1
1 141
1 146
1 151
1 156
1 161
166 1
171 1
176 1
1 181
186 1
1 191
1 196
201 1
206 1
1 211
216 1
221 1
226 1
231 1
236 1
241 1
246 1
251 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 #86:

score: 0
Accepted
time: 205ms
memory: 6092kb

input:

99970 100000
3 1
4 1
5 1
1 6
11 1
1 16
1 21
1 26
1 31
36 1
1 41
46 1
1 51
1 56
1 61
66 1
1 71
1 76
81 1
1 86
91 1
96 1
1 101
106 1
111 1
1 116
121 1
126 1
131 1
136 1
141 1
146 1
151 1
1 156
1 161
166 1
1 171
1 176
181 1
186 1
191 1
1 196
201 1
206 1
1 211
216 1
221 1
226 1
231 1
236 1
1 241
246 1
2...

output:

2
1
40000
39999
60032
64
63
20032
62
61
60
59
58
57
60031
39998
60030
56
55
54
53
52
3
51
50
49
48
47
46
20031
20030
20029
45
44
19997
20028
59984
43
42
60029
41
40
39
39997
80000
39996
20027
20026
20025
39995
39994
38
37
36
35
0
34
33
32
31
30
29
28
27
26
60028
60027
20024
20023
20022
25
24
23
2002...

result:

ok q=100000

Test #87:

score: 0
Accepted
time: 589ms
memory: 6236kb

input:

99970 100000
1 3
5 1
6 1
1 11
1 16
1 21
1 26
31 1
1 36
41 1
1 46
51 1
56 1
1 61
1 66
1 71
76 1
81 1
1 86
1 91
1 96
1 101
1 106
111 1
116 1
1 121
1 126
1 131
136 1
1 141
1 146
151 1
1 156
161 1
1 166
171 1
1 176
181 1
1 186
1 191
196 1
1 201
1 206
1 211
216 1
1 221
1 226
1 231
236 1
241 1
246 1
1 251...

output:

1
40000
0
20032
20031
20030
20029
20028
0
0
0
0
0
20027
64
63
62
61
60
59
58
57
56
55
54
53
52
2
20026
20025
20024
20023
20022
20021
20020
20019
0
20018
20017
20016
20015
51
50
20014
20013
20012
20011
20010
49
48
47
46
45
44
43
42
41
40
39
38
37
36
35
34
33
32
31
30
29
28
27
26
25
24
23
20009
20008
...

result:

ok q=100000

Test #88:

score: 0
Accepted
time: 151ms
memory: 5664kb

input:

99970 100000
1 3
1 4
1 5
1 6
7 1
1 13
1 19
25 1
31 1
1 37
1 43
49 1
55 1
1 61
1 67
1 73
79 1
85 1
91 1
1 97
103 1
109 1
115 1
121 1
1 127
133 1
139 1
145 1
1 151
157 1
1 163
169 1
1 175
181 1
1 187
1 193
1 199
1 205
1 211
1 217
223 1
229 1
1 235
1 241
1 247
253 1
259 1
1 265
271 1
277 1
1 283
1 289
...

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 #89:

score: 0
Accepted
time: 134ms
memory: 5684kb

input:

99970 100000
3 1
1 4
5 1
6 1
7 1
13 1
19 1
1 25
1 31
37 1
43 1
1 49
1 55
1 61
1 67
73 1
1 79
1 85
1 91
1 97
1 103
109 1
115 1
121 1
127 1
133 1
139 1
1 145
151 1
1 157
1 163
1 169
1 175
1 181
187 1
1 193
1 199
1 205
1 211
1 217
223 1
229 1
235 1
1 241
247 1
1 253
1 259
1 265
1 271
1 277
1 283
289 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 #90:

score: 0
Accepted
time: 194ms
memory: 6344kb

input:

99970 100000
1 2
1 3
1 4
7 1
13 1
1 19
25 1
31 1
37 1
1 43
1 49
55 1
61 1
1 67
73 1
1 79
85 1
1 91
97 1
1 103
109 1
115 1
121 1
1 127
1 133
139 1
1 145
1 151
1 157
1 163
169 1
1 175
181 1
187 1
1 193
1 199
205 1
1 211
1 217
1 223
229 1
1 235
1 241
1 247
253 1
1 259
1 265
271 1
1 277
1 283
289 1
1 29...

output:

33327
49990
1
16704
2
16665
66652
3
83328
0
50048
50047
33344
33343
33342
16703
16702
16701
16700
16699
16698
64
63
62
61
16697
16696
60
59
33341
33340
50046
50045
0
83327
16695
16694
16693
83326
49989
66688
0
50044
50043
50042
50041
33339
16692
16691
33338
33337
58
57
56
16690
16689
16688
16687
166...

result:

ok q=100000

Test #91:

score: 0
Accepted
time: 561ms
memory: 6148kb

input:

99970 100000
3 1
6 1
1 7
13 1
19 1
25 1
1 31
1 37
1 43
1 49
55 1
61 1
67 1
1 73
1 79
1 85
1 91
97 1
103 1
109 1
1 115
121 1
127 1
133 1
139 1
145 1
151 1
157 1
163 1
169 1
175 1
181 1
187 1
193 1
199 1
205 1
1 211
217 1
223 1
229 1
1 235
1 241
247 1
1 253
259 1
265 1
271 1
277 1
1 283
1 289
295 1
1 ...

output:

16704
1
16703
16702
64
63
62
61
60
59
58
57
56
55
54
16664
33344
33343
33342
33341
53
52
51
50
49
48
47
46
45
44
43
42
41
40
39
38
37
36
35
34
16701
2
16666
16665
33329
33328
50048
50047
33
32
31
30
29
28
27
26
33340
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
9
33339
33338
33337
16700
16699
166...

result:

ok q=100000

Test #92:

score: 0
Accepted
time: 144ms
memory: 5480kb

input:

99970 100000
3 1
1 4
5 1
1 8
15 1
22 1
1 29
1 36
1 43
50 1
1 57
1 64
71 1
78 1
1 85
1 92
99 1
1 106
1 113
1 120
1 127
1 134
1 141
1 148
1 155
162 1
169 1
176 1
1 183
190 1
197 1
1 204
1 211
218 1
225 1
232 1
239 1
1 246
1 253
260 1
1 267
274 1
1 281
288 1
295 1
302 1
309 1
316 1
1 323
330 1
1 337
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 #93:

score: 0
Accepted
time: 134ms
memory: 6124kb

input:

99970 100000
1 3
1 5
6 1
7 1
1 8
15 1
22 1
29 1
36 1
1 43
50 1
57 1
64 1
1 71
1 78
1 85
92 1
1 99
106 1
113 1
1 120
127 1
134 1
141 1
148 1
155 1
1 162
169 1
176 1
1 183
190 1
197 1
204 1
211 1
1 218
1 225
232 1
239 1
246 1
1 253
1 260
267 1
274 1
1 281
1 288
1 295
1 302
1 309
316 1
323 1
1 330
337 ...

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 #94:

score: 0
Accepted
time: 178ms
memory: 6148kb

input:

99970 100000
2 1
1 3
1 5
1 7
8 1
15 1
1 22
1 29
36 1
43 1
50 1
57 1
1 64
1 71
78 1
85 1
1 92
1 99
106 1
113 1
120 1
127 1
134 1
141 1
1 148
1 155
162 1
169 1
1 176
1 183
190 1
197 1
204 1
1 211
218 1
225 1
1 232
239 1
1 246
253 1
1 260
267 1
274 1
1 281
288 1
1 295
302 1
1 309
1 316
1 323
330 1
337 ...

output:

4
3
14288
2
1
64
63
14286
28608
14336
14335
62
61
28607
60
59
58
57
56
55
54
53
52
51
50
49
14287
14334
14333
14332
14331
14330
14329
14328
14327
14326
14325
14324
14323
42853
14322
14321
14320
14319
14318
14317
28571
48
47
42854
14316
14315
46
45
14314
14313
14312
14311
14310
14309
14308
28606
44
4...

result:

ok q=100000

Test #95:

score: 0
Accepted
time: 558ms
memory: 6304kb

input:

99970 100000
2 1
3 1
4 1
1 6
7 1
8 1
1 15
1 22
29 1
1 36
1 43
50 1
1 57
1 64
71 1
78 1
1 85
1 92
1 99
106 1
113 1
1 120
1 127
1 134
141 1
1 148
155 1
1 162
1 169
176 1
1 183
1 190
197 1
1 204
1 211
218 1
1 225
1 232
239 1
246 1
253 1
1 260
267 1
1 274
281 1
1 288
1 295
1 302
1 309
1 316
323 1
330 1
...

output:

0
0
4
14288
5
2
3
28608
28607
28606
42853
57134
28605
28604
28603
28602
28601
28600
71424
71423
71422
71421
71420
71419
71418
14287
64
63
62
61
60
59
28599
28598
28597
28596
28595
28594
28593
28592
28591
28590
28589
28588
28587
28586
28585
28584
28583
28582
28581
28580
28579
28578
28577
28576
28575
...

result:

ok q=100000

Test #96:

score: 0
Accepted
time: 151ms
memory: 5584kb

input:

99970 100000
2 1
3 1
4 1
1 5
1 6
9 1
17 1
25 1
33 1
1 41
49 1
57 1
65 1
73 1
1 81
89 1
1 97
1 105
113 1
1 121
1 129
137 1
145 1
153 1
1 161
1 169
1 177
1 185
1 193
1 201
1 209
217 1
1 225
1 233
1 241
1 249
1 257
1 265
1 273
281 1
1 289
297 1
1 305
313 1
321 1
1 329
337 1
1 345
1 353
361 1
369 1
1 37...

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 #97:

score: 0
Accepted
time: 153ms
memory: 5848kb

input:

99970 100000
1 2
1 4
1 5
1 6
1 9
1 17
25 1
33 1
41 1
1 49
57 1
1 65
1 73
81 1
89 1
97 1
1 105
113 1
1 121
129 1
137 1
145 1
1 153
161 1
169 1
1 177
185 1
193 1
1 201
209 1
217 1
1 225
1 233
1 241
249 1
257 1
1 265
273 1
281 1
289 1
297 1
305 1
1 313
321 1
329 1
337 1
345 1
353 1
1 361
369 1
377 1
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 #98:

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

input:

99970 100000
4 1
5 1
1 8
1 9
17 1
25 1
1 33
1 41
1 49
57 1
65 1
1 73
1 81
1 89
97 1
105 1
1 113
1 121
1 129
137 1
145 1
1 153
1 161
169 1
177 1
185 1
1 193
1 201
1 209
217 1
1 225
1 233
241 1
1 249
1 257
265 1
1 273
1 281
289 1
297 1
305 1
1 313
1 321
329 1
337 1
345 1
1 353
1 361
1 369
377 1
1 385
...

output:

1
12544
12543
12542
64
63
62
61
2
12504
12502
12501
12503
25001
37498
49995
60
59
58
57
56
55
54
53
52
51
50
49
48
47
46
45
44
43
42
41
12541
12540
12539
40
39
38
37
36
35
34
12500
33
32
31
30
29
28
27
26
25
24
23
22
21
20
12538
12537
12536
75008
3
12535
12534
12533
19
18
17
16
15
12532
12531
14
13
...

result:

ok q=100000

Test #99:

score: 0
Accepted
time: 543ms
memory: 6164kb

input:

99970 100000
6 1
9 1
1 17
1 25
1 33
41 1
1 49
1 57
1 65
73 1
1 81
89 1
97 1
1 105
113 1
1 121
129 1
137 1
1 145
1 153
1 161
169 1
1 177
1 185
1 193
201 1
209 1
217 1
1 225
1 233
1 241
249 1
257 1
265 1
1 273
281 1
1 289
1 297
1 305
313 1
321 1
1 329
337 1
345 1
353 1
361 1
369 1
1 377
1 385
393 1
1 ...

output:

0
0
0
12500
37496
12502
50048
50047
12544
1
12543
12542
12541
12540
12501
25000
49993
64
63
62528
62527
62489
62526
62525
62524
62523
62522
12503
37497
62490
12499
62
61
60
59
58
57
56
55
54
53
52
51
50
49
48
47
46
37504
37503
37502
37501
37500
37499
37498
12498
25024
25023
12539
12538
12537
12536
1...

result:

ok q=100000

Test #100:

score: 0
Accepted
time: 100ms
memory: 5060kb

input:

10000 100000
62 1
1 552
818 1
1 1204
1993 1
1 4007
1 4095
5262 1
1 5367
5784 1
1 6036
6091 1
1 6559
8108 1
1 8154
1 9191
9482 1
41 2
2 294
1572 2
1852 2
2 1895
3322 2
4360 2
4905 2
2 5027
5934 2
6198 2
6504 2
2 6870
8364 2
722 3
812 3
1347 3
1856 3
1990 3
2008 3
2578 3
3 3019
3 3248
3 3495
3 3616
3 ...

output:

59

result:

ok q=100000

Test #101:

score: 0
Accepted
time: 253ms
memory: 5448kb

input:

10000 100000
1 278
1 1411
1906 1
2107 1
2178 1
1 2299
2526 1
1 2856
1 3613
3796 1
1 4128
1 4196
1 4250
1 4631
5135 1
5224 1
1 5279
6206 1
1 6985
1 7310
1 7357
7722 1
7815 1
1 8282
9362 1
9571 1
1 9782
1 9999
874 2
2 1055
1187 2
2010 2
2 2173
2250 2
2511 2
2699 2
2756 2
2876 2
2 3802
4047 2
4937 2
2 ...

output:

3264
242
2307
72
241
995
199
123
259
928
1040
1130
59
1434
1701
427
323
214
610
605
2
1025
1762
1871
741
740
739
738
737
736
182
735
734
733
732
731
319
730
67
216
105
350
702
561
729
728
727
726
725
724
801
138
643
1023
256
263
723
104
722
721
426
460
720
510
704
703
248
701
584
437
700
699
698
697...

result:

ok q=100000

Test #102:

score: 0
Accepted
time: 487ms
memory: 6016kb

input:

10000 100000
1 257
1 1150
1 2495
4714 1
5052 1
5128 1
5130 1
1 5235
1 6273
1 7279
7296 1
1 7899
8429 1
8895 1
9133 1
1 9402
2 378
2 434
1060 2
2991 2
5009 2
5316 2
2 5857
2 5984
2 6490
2 6494
6963 2
2 7560
2 7816
7996 2
8202 2
2 8218
2 9608
893 3
3 1127
3 1318
1863 3
3136 3
3 3927
4162 3
4273 3
3 49...

output:

0
7465
1614
251
1910
679
2242
1693
2359
2455
693
692
691
690
539
689
688
687
686
685
684
683
682
681
966
1369
1960
2420
1997
2324
456
2419
1260
694
1224
49
2418
2417
1581
2416
1809
2415
2414
2413
2412
1210
2251
2411
2410
472
249
1066
1374
1625
886
1837
2322
2409
379
972
1383
112
184
1031
2176
1100
2...

result:

ok q=100000

Test #103:

score: 0
Accepted
time: 658ms
memory: 5604kb

input:

10000 100000
1 32
366 1
1164 1
1 1881
2317 1
2931 1
1 2932
3853 1
4011 1
1 4090
1 5006
5656 1
5696 1
1 6055
6674 1
7367 1
7599 1
8265 1
2 1468
2 1486
1670 2
2375 2
2 2729
3116 2
2 3202
2 3560
2 4047
2 4643
2 4645
4794 2
4958 2
5887 2
5947 2
2 6549
2 6992
2 7179
7436 2
2 7513
2 8130
2 8703
2 9686
514...

output:

0
15116
17567
17657
11119
13910
5148
12807
1807
4
4181
5416
5415
2369
299
548
4648
5414
5413
5412
5411
5410
5409
5408
5407
494
1182
1471
5438
5406
5405
5404
5403
5101
5402
5401
5400
5399
5398
1785
5397
3900
3883
5396
5639
5703
6151
402
3675
1946
3804
568
783
4340
4363
4526
5010
5009
5008
5007
5006
5...

result:

ok q=100000

Test #104:

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

input:

10000 100000
1 1173
1 2045
1 2146
1 2314
2389 1
1 2586
1 2796
1 3622
3650 1
1 3692
1 3985
4433 1
4520 1
5493 1
1 5514
6563 1
7220 1
1 7472
1 8043
1 8385
8565 1
9622 1
1 9735
2 97
2 131
167 2
1663 2
3416 2
2 4187
2 4386
2 4447
2 5022
5025 2
5179 2
2 5885
2 6919
8335 2
8400 2
2 8671
8807 2
9147 2
3 83...

output:

0
0
0
0
8931
18034
3368
3646
6002
5064
7532
3102
1223
423
3857
4792
5281
606
1525
2127
5489
910
1112
2662
2741
4591
5484
3296
5701
5902
1152
6095
6456
6598
651
737
1379
2695
2918
3573
4811
6904
7406
7766
7953
2529
2235
2871
4448
5761
6638
2258
3257
3810
4257
4530
4525
5305
5411
8546
8697
8858
9017
9...

result:

ok q=100000

Test #105:

score: 0
Accepted
time: 401ms
memory: 5900kb

input:

10000 100000
1 380
1 873
1 1618
1838 1
1 2767
3506 1
1 4453
4602 1
4754 1
4880 1
1 5778
1 5811
1 6230
7868 1
1 7911
8126 1
1 8233
9049 1
9356 1
2 10
2 537
658 2
2 1129
1461 2
2 2035
2237 2
3097 2
3513 2
2 3524
2 3931
2 4956
5072 2
2 5204
2 5302
2 5454
2 5562
5607 2
5774 2
2 5909
6017 2
2 6193
6622 2...

output:

0
27150
30684
36735
38811
39253
49145
64431
12441
15385
18770
21325
23949
24041
5091
15944
35025
41047
41532
41975
52191
54021
6692
18808
30169
32734
55281
55535
55524
55733
783
2886
9536
9535
9534
9533
9532
9531
9530
621
4684
4910
7271
8808
9529
4590
5105
6046
9528
9527
9545
9544
9543
9542
9541
954...

result:

ok q=100000

Test #106:

score: 0
Accepted
time: 117ms
memory: 5736kb

input:

10000 100000
1 223
924 1
1010 1
1 2164
1 2599
3130 1
3294 1
1 3555
1 3759
4080 1
1 4841
4948 1
1 5358
1 6539
7363 1
1 7747
9377 1
1 9393
1 9596
1 9941
376 2
2 623
878 2
1665 2
1759 2
2 1941
2135 2
3573 2
3685 2
3843 2
2 4021
5156 2
2 6157
2 6758
6934 2
2 7220
2 7354
7620 2
2 7815
2 8287
2 8564
8772 ...

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 #107:

score: 0
Accepted
time: 106ms
memory: 5052kb

input:

10000 100000
1 246
483 1
1 766
1 1389
1 1977
1 2314
2563 1
2637 1
2826 1
1 4125
4414 1
4737 1
1 5172
1 5460
1 5727
1 6441
1 6611
1 6654
1 7016
7208 1
1 7265
1 7459
7666 1
1 7680
1 7784
8265 1
8518 1
9031 1
2 1115
2 1194
2 1496
1533 2
2 1578
1655 2
2455 2
2 2537
2785 2
2 3661
2 5953
2 6095
2 6250
728...

output:

63

result:

ok q=100000

Test #108:

score: 0
Accepted
time: 250ms
memory: 6020kb

input:

10000 100000
1 4
1 262
480 1
1661 1
1942 1
3141 1
3242 1
1 4520
5039 1
5322 1
5617 1
5702 1
6596 1
7549 1
8091 1
1 8150
1 8300
8880 1
8976 1
9057 1
1 9615
2 361
986 2
2 1260
1571 2
1831 2
2903 2
2 3659
2 4398
4775 2
4780 2
2 5425
6353 2
2 6520
2 7157
2 7742
2 8973
9025 2
50 3
3 677
3 816
924 3
1742 ...

output:

63
62
61
60
59
58
57
56
54
53
52
51
49
47
46
39
34
31
28
27
25
23
21
19
18
16
14
13
11
4
1
127
123
122
119
114
112
109
107
106
97
96
95
94
88
86
85
83
80
79
77
76
75
74
190
189
188
187
183
182
180
179
178
176
184
174
172
92
171
169
167
166
165
159
158
157
155
153
152
147
146
145
142
140
78
139
133
1...

result:

ok q=100000

Test #109:

score: 0
Accepted
time: 467ms
memory: 5584kb

input:

10000 100000
637 1
1879 1
1 2512
1 3578
3828 1
4117 1
1 4420
4468 1
4698 1
1 6029
6048 1
6553 1
6615 1
1 6970
7457 1
7626 1
1 7647
1 9559
9862 1
2 362
2 2514
2764 2
2 2982
3679 2
6566 2
2 8237
8441 2
8654 2
8754 2
8796 2
2 8905
9184 2
3 1285
3 1795
2932 3
3 3025
3 3149
3 3537
5987 3
3 6361
3 6710
3 ...

output:

64
59
53
52
50
49
47
44
41
38
36
34
32
30
29
27
26
25
24
17
14
13
10
9
8
22
7
6
5
4
3
1
127
126
125
121
118
116
111
109
103
101
100
99
95
94
92
91
90
88
87
85
84
83
82
81
76
75
74
73
70
69
68
67
188
186
185
183
123
182
79
180
178
175
169
168
167
166
164
163
161
158
154
153
152
151
149
147
146
144
14...

result:

ok q=100000

Test #110:

score: 0
Accepted
time: 633ms
memory: 5452kb

input:

10000 100000
6 1
1 399
891 1
1 1247
1269 1
1 1839
1 4072
4089 1
1 4245
1 4901
5339 1
1 7182
7459 1
8149 1
8208 1
1 8881
8937 1
1 9259
2 997
2 1065
2 2100
2 2796
2 3802
2 4857
2 5518
2 5539
5952 2
2 5973
7487 2
2 8574
2 9917
61 3
3 70
591 3
3 594
3 1502
3 1606
3 1616
3106 3
3 3523
3 3742
3 4162
4550 ...

output:

63
62
60
59
57
56
53
52
51
49
48
47
46
44
42
41
40
36
30
29
23
22
21
19
15
12
11
9
8
6
5
125
123
122
121
119
117
113
110
109
107
106
103
102
101
100
99
92
88
85
84
79
75
72
71
70
69
68
190
187
183
181
178
176
175
174
169
167
165
163
162
157
156
155
148
146
144
142
140
139
137
135
154
133
130
129
255...

result:

ok q=100000

Test #111:

score: 0
Accepted
time: 574ms
memory: 5372kb

input:

10000 100000
1 362
793 1
1 2340
1 2929
1 3619
1 3663
1 3789
6135 1
6331 1
6700 1
1 6901
7815 1
8192 1
1 8615
8676 1
1 8849
1 9273
1 9310
323 2
512 2
2 847
2 967
2 970
1006 2
1716 2
2102 2
2 2739
3298 2
2 3444
2 3472
3889 2
2 4569
2 5985
6892 2
7135 2
7675 2
7854 2
7871 2
8179 2
8656 2
8719 2
2 8799
...

output:

63
62
60
57
55
53
51
50
48
46
42
40
39
38
34
33
31
30
27
25
20
17
16
14
12
11
9
8
7
5
126
125
123
121
119
118
117
115
113
112
109
107
104
103
99
98
96
93
90
85
79
78
77
76
75
73
72
69
67
66
65
192
187
179
178
176
175
172
170
169
166
163
162
161
160
159
156
155
153
149
148
146
144
142
138
134
133
130...

result:

ok q=100000

Test #112:

score: 0
Accepted
time: 384ms
memory: 5588kb

input:

10000 100000
1 53
1 1122
1949 1
1965 1
1 2760
1 6345
6354 1
1 6764
1 7825
1 8453
8734 1
9046 1
1 9160
9875 1
2 29
167 2
754 2
2 867
1007 2
1040 2
2 1421
2752 2
2 3046
2 3444
2 3627
2 4830
2 5453
2 6492
2 8157
2 8480
2 9226
2 9460
9525 2
369 3
572 3
3 648
1053 3
3 1356
3 2369
3153 3
3155 3
3 5471
604...

output:

62
58
57
54
53
51
50
46
44
43
41
36
33
32
31
30
28
26
25
22
21
20
17
12
8
7
6
3
2
128
124
123
122
117
115
114
112
111
110
109
104
102
100
99
97
94
90
89
88
86
85
84
81
80
73
70
68
67
116
113
108
107
106
105
103
101
66
192
191
189
188
187
186
182
181
179
176
175
174
173
171
170
169
168
165
163
162
16...

result:

ok q=100000

Test #113:

score: 0
Accepted
time: 121ms
memory: 4896kb

input:

10000 100000
303 1
1 306
1 309
603 1
1 624
1 713
1 954
1019 1
1921 1
2013 1
1 2239
2768 1
1 2899
4285 1
4773 1
1 5281
1 5596
5739 1
5755 1
5849 1
6228 1
1 7029
1 7255
7597 1
7679 1
9099 1
1 9342
966 2
2 1630
2 1984
2339 2
2 2603
2 3021
2 3661
2 3766
6428 2
2 7230
2 7652
7773 2
7997 2
9437 2
9475 2
9...

output:

64
63
61
57
56
51
50
44
42
37
33
32
31
30
26
24
23
21
17
15
13
11
8
7
6
3
2
1
127
126
125
124
122
119
118
117
116
114
113
112
111
108
105
101
96
94
93
92
89
87
86
85
83
82
80
75
74
73
72
71
69
66
191
189
187
185
183
182
180
178
177
173
170
168
167
166
162
159
156
155
153
147
146
143
141
139
138
136
...

result:

ok q=100000

Test #114:

score: 0
Accepted
time: 107ms
memory: 5212kb

input:

10000 100000
1 687
1 2238
2339 1
2540 1
3744 1
1 4048
1 5868
1 6041
7833 1
8786 1
9222 1
935 2
2 1185
2 1659
1973 2
2 2048
2 2569
3163 2
3286 2
2 4612
5511 2
2 5535
5942 2
2 6222
2 6365
2 6547
6954 2
2 7976
8670 2
9133 2
2 9507
1116 3
1283 3
3 1886
3 2675
4460 3
5444 3
3 6072
3 7681
8072 3
8104 3
3 ...

output:

63

result:

ok q=100000

Test #115:

score: 0
Accepted
time: 234ms
memory: 5608kb

input:

10000 100000
16 1
1 226
1 546
1 751
1 1332
1 2446
2702 1
2853 1
4522 1
4669 1
1 4771
1 5035
5108 1
1 5221
1 5265
5519 1
8583 1
1 8612
1 9249
1 9798
20 2
2 312
534 2
689 2
1484 2
2304 2
2351 2
2 3520
2 3886
4324 2
4432 2
4630 2
4977 2
6737 2
7547 2
2 7610
2 7638
7669 2
7678 2
7894 2
2 8781
2 8824
904...

output:

275
404
489
472
589
93
756
742
826
133
326
238
277
83
353
736
114
447
778
735
774
1007
995
15
55
266
869
706
1073
1066
1040
1036
1176
1324
1398
940
1527
398
1375
1516
1489
485
902
1067
1475
1586
567
1173
1305
734
1575
1556
311
758
951
538
516
927
966
237
1194
1456
1595
1361
1625
1616
126
703
983
128...

result:

ok q=100000

Test #116:

score: 0
Accepted
time: 456ms
memory: 5588kb

input:

10000 100000
1 634
1 773
973 1
1993 1
1 2206
1 2258
1 2674
2934 1
3289 1
1 3486
1 3665
3870 1
1 4202
1 4222
4916 1
1 5131
5341 1
1 5589
1 7234
1 7419
1 7603
1 7647
1 7871
1 7887
8704 1
2 165
2 334
2 896
2 1110
1438 2
1649 2
1824 2
2158 2
2 2205
2781 2
2 2912
2 4077
2 4501
4528 2
2 5391
2 5496
2 5811...

output:

0
1508
4333
4747
4708
7890
7873
9421
9687
236
1332
1465
2850
3772
29
246
5490
5509
1176
1975
968
2153
2119
261
584
1510
1921
2393
2944
2943
2942
368
1477
2941
2940
2939
1546
542
744
2938
2937
2936
2935
2934
2933
322
2955
2954
232
351
438
847
1158
1602
1931
2077
2181
2953
2952
2951
1460
2950
2949
294...

result:

ok q=100000

Test #117:

score: 0
Accepted
time: 609ms
memory: 6352kb

input:

10000 100000
141 1
1 864
1 1515
1 1659
1 1665
1 1986
1 2432
2546 1
1 2598
1 2721
2792 1
3557 1
3736 1
1 7164
7510 1
1 9187
9424 1
2 2738
2 2936
3033 2
2 4575
4971 2
2 5719
6196 2
2 6465
2 6500
2 6665
2 7093
7520 2
2 7675
2 9723
3 130
3 279
755 3
3 964
1475 3
1750 3
3 1879
3 1961
3 2223
3 3125
3 3484...

output:

0
7607
3877
299
1280
1413
2408
3876
3875
3874
1883
3873
110
2339
1780
3872
3871
3870
3869
3868
218
1498
1814
3867
3866
3865
3864
3863
3862
3861
3860
4185
4294
1824
2014
2689
3165
3901
4543
4990
5470
6001
318
402
1627
3595
5041
6144
3946
6143
6142
6141
3304
306
4137
4169
12
4400
5554
6140
6139
6138
6...

result:

ok q=100000

Test #118:

score: 0
Accepted
time: 556ms
memory: 5380kb

input:

10000 100000
1 496
1 976
1674 1
1 2091
1 2796
1 3047
1 3734
1 4361
1 4620
6855 1
1 6896
1 8073
8352 1
1 8572
8781 1
1 8857
1 8915
1 9035
1 9294
9490 1
9985 1
673 2
855 2
2 1012
1711 2
2 1902
2426 2
2 2597
2960 2
2 4925
2 5659
7946 2
7990 2
2 8450
2 8638
2 8646
2 8918
9379 2
3 443
3 458
3 1247
3 1405...

output:

20635
29135
4243
18271
19650
24146
29979
3482
5947
11811
2766
7597
10929
11220
5669
11219
11218
11217
897
3439
4434
11216
11215
11214
11213
337
4227
5836
8877
9877
4836
10534
11212
11211
11210
1133
1628
1239
349
857
1772
3963
6057
6113
6441
7562
7850
9777
10371
4366
10539
4230
4410
10523
6562
10941
...

result:

ok q=100000

Test #119:

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

input:

10000 100000
155 1
1 312
458 1
1 1772
1 2247
2334 1
1 2939
1 3031
4298 1
1 4460
1 6773
6873 1
7230 1
7285 1
7408 1
8385 1
1 8469
1 9022
9310 1
245 2
883 2
2 1068
1159 2
2 1844
2 2177
2 2407
2670 2
2820 2
2 2948
3701 2
3801 2
2 4259
2 4406
4662 2
5265 2
2 6295
7931 2
9316 2
2 9595
88 3
125 3
1259 3
3...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
4129
6177
12294
19229
19563
20671
38728
42535
42534
42533
42532
42531
3917
7655
10294
6092
13776
13775
13774
13773
13772
13771
13770
13769
13768
13767
13766
13765
13764
9738
14398
14504
14499
19361
23079
25894
26817
26952
11540
14267
26737
27179
27224
31762
10293
21202
2833...

result:

ok q=100000

Test #120:

score: 0
Accepted
time: 115ms
memory: 5764kb

input:

10000 100000
121 1
1 242
1 1247
1325 1
1 1445
2211 1
2687 1
3212 1
1 3458
1 4405
1 4473
5781 1
1 5987
6973 1
7680 1
1 9000
9059 1
1 9514
9600 1
51 2
2 693
1286 2
1391 2
2 1705
2 3339
3471 2
2 3864
2 5097
2 5130
5658 2
2 6647
6819 2
2 7138
2 7764
2 7810
8298 2
2 8369
8894 2
2 9880
3 53
3 625
3 779
14...

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 #121:

score: 0
Accepted
time: 102ms
memory: 4824kb

input:

9970 100000
2 1
3 1
1 4
1 5
1 6
1 7
8 1
1 9
10 1
1 11
1 12
1 13
14 1
1 15
1 16
17 1
18 1
19 1
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
1 33
1 34
35 1
1 36
37 1
1 38
39 1
40 1
41 1
1 42
43 1
1 44
45 1
1 46
47 1
48 1
1 49
50 1
1 51
52 1
53 1
1 54
55 1
1 56
1 57
1 58
1 59
1 60
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 #122:

score: 0
Accepted
time: 103ms
memory: 4980kb

input:

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

score: 0
Accepted
time: 107ms
memory: 5368kb

input:

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

output:

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

result:

ok q=100000

Test #124:

score: 0
Accepted
time: 474ms
memory: 5112kb

input:

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

output:

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

result:

ok q=100000

Test #125:

score: 0
Accepted
time: 118ms
memory: 4888kb

input:

9970 100000
1 2
3 1
1 5
7 1
1 9
11 1
1 13
15 1
17 1
19 1
21 1
1 23
25 1
1 27
1 29
1 31
1 33
35 1
37 1
39 1
1 41
43 1
45 1
47 1
1 49
1 51
1 53
1 55
1 57
1 59
61 1
1 63
65 1
1 67
69 1
71 1
1 73
1 75
77 1
1 79
1 81
83 1
1 85
1 87
1 89
1 91
1 93
1 95
1 97
1 99
101 1
1 103
1 105
1 107
109 1
111 1
113 1
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 #126:

score: 0
Accepted
time: 114ms
memory: 4992kb

input:

9970 100000
2 1
3 1
5 1
1 7
9 1
1 11
13 1
1 15
17 1
19 1
1 21
23 1
1 25
1 27
29 1
1 31
33 1
35 1
37 1
1 39
41 1
43 1
1 45
1 47
49 1
1 51
53 1
55 1
1 57
1 59
61 1
63 1
1 65
1 67
1 69
1 71
73 1
1 75
1 77
79 1
1 81
1 83
1 85
87 1
89 1
91 1
93 1
95 1
1 97
1 99
1 101
103 1
105 1
107 1
109 1
111 1
1 113
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 #127:

score: 0
Accepted
time: 142ms
memory: 5264kb

input:

9970 100000
1 2
1 3
1 5
1 7
9 1
11 1
13 1
1 15
1 17
19 1
1 21
1 23
25 1
1 27
1 29
1 31
1 33
35 1
37 1
1 39
41 1
1 43
45 1
1 47
1 49
51 1
53 1
55 1
1 57
59 1
1 61
1 63
1 65
1 67
1 69
1 71
1 73
75 1
77 1
79 1
1 81
83 1
85 1
87 1
89 1
1 91
93 1
1 95
97 1
1 99
101 1
103 1
1 105
1 107
1 109
111 1
1 113
1...

output:

64
0
1
63
62
61
60
0
4992
59
4991
58
57
56
55
0
4990
0
4989
0
4988
54
4987
53
4986
52
5056
0
5055
0
51
50
5054
49
48
0
5053
47
46
0
45
44
43
0
42
41
5052
40
5051
39
38
0
5050
0
5049
0
5048
0
5047
0
37
36
35
0
34
0
33
32
5046
31
30
29
28
27
5045
0
5044
0
5043
26
25
24
23
22
21
0
5042
0
5041
20
19
18
...

result:

ok q=100000

Test #128:

score: 0
Accepted
time: 519ms
memory: 5336kb

input:

9970 100000
1 2
1 3
1 5
7 1
1 9
1 11
1 13
1 15
17 1
1 19
21 1
23 1
25 1
1 27
1 29
1 31
33 1
35 1
1 37
39 1
1 41
1 43
1 45
47 1
49 1
1 51
53 1
1 55
57 1
59 1
61 1
63 1
65 1
67 1
1 69
1 71
1 73
1 75
1 77
79 1
81 1
1 83
85 1
87 1
1 89
1 91
93 1
1 95
1 97
1 99
101 1
103 1
1 105
107 1
109 1
1 111
1 113
1...

output:

0
0
0
0
1
4992
4991
4990
64
63
4989
62
61
4988
4987
4986
0
60
59
5056
5055
58
57
56
55
54
53
52
51
50
49
48
0
47
0
5054
5053
46
45
0
0
44
43
42
5052
0
5051
0
0
41
40
0
0
0
0
0
0
39
38
37
36
35
34
33
32
5050
5049
5048
5047
0
0
31
30
29
28
0
27
0
26
25
24
23
22
5046
5045
5044
21
20
19
18
17
16
15
14
1...

result:

ok q=100000

Test #129:

score: 0
Accepted
time: 122ms
memory: 4944kb

input:

9970 100000
3 1
1 4
7 1
1 10
13 1
16 1
1 19
22 1
25 1
1 28
31 1
1 34
37 1
1 40
43 1
1 46
49 1
52 1
1 55
58 1
1 61
1 64
1 67
1 70
73 1
1 76
1 79
1 82
1 85
1 88
91 1
94 1
97 1
100 1
103 1
1 106
109 1
112 1
1 115
1 118
121 1
124 1
1 127
130 1
133 1
136 1
139 1
1 142
145 1
1 148
1 151
1 154
1 157
160 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 #130:

score: 0
Accepted
time: 121ms
memory: 5004kb

input:

9970 100000
3 1
1 4
7 1
10 1
13 1
1 16
19 1
1 22
25 1
1 28
1 31
1 34
1 37
1 40
43 1
1 46
1 49
1 52
1 55
1 58
1 61
1 64
1 67
1 70
73 1
1 76
79 1
1 82
1 85
1 88
1 91
1 94
1 97
1 100
1 103
1 106
1 109
1 112
1 115
118 1
1 121
124 1
127 1
130 1
1 133
1 136
1 139
1 142
1 145
1 148
151 1
154 1
1 157
1 160
...

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 #131:

score: 0
Accepted
time: 115ms
memory: 5140kb

input:

9970 100000
2 1
3 1
1 4
1 7
10 1
1 13
1 16
19 1
22 1
25 1
1 28
1 31
1 34
37 1
1 40
1 43
1 46
49 1
1 52
1 55
1 58
1 61
1 64
67 1
1 70
73 1
1 76
1 79
82 1
1 85
1 88
91 1
94 1
97 1
100 1
1 103
1 106
109 1
1 112
115 1
118 1
121 1
1 124
1 127
1 130
133 1
1 136
139 1
1 142
145 1
1 148
1 151
1 154
1 157
16...

output:

2
64
6656
63
6655
1
6654
0
3328
3327
3326
62
61
3392
3391
60
3390
59
3389
3388
6653
58
6652
3387
3386
57
56
55
6651
0
6650
54
53
52
51
50
49
48
3385
47
3384
0
6649
3383
3382
0
6648
0
3381
46
3380
45
3379
44
43
3378
42
41
40
3377
3376
0
3375
3374
6720
3373
3372
39
38
0
3371
0
3370
37
36
35
34
33
32
3...

result:

ok q=100000

Test #132:

score: 0
Accepted
time: 499ms
memory: 5328kb

input:

9970 100000
1 2
1 3
4 1
7 1
1 10
13 1
16 1
1 19
22 1
25 1
1 28
1 31
1 34
1 37
40 1
43 1
46 1
1 49
1 52
1 55
1 58
1 61
64 1
1 67
70 1
1 73
76 1
1 79
82 1
1 85
1 88
91 1
1 94
1 97
1 100
1 103
1 106
109 1
1 112
1 115
118 1
121 1
124 1
127 1
130 1
133 1
1 136
1 139
142 1
145 1
1 148
151 1
1 154
1 157
1 ...

output:

2
64
6656
1
6655
6654
0
0
3328
3327
3326
63
3392
3391
3390
3389
62
3388
3387
3386
3385
3384
61
60
59
58
57
56
55
54
53
52
51
3383
50
49
48
47
46
45
44
43
42
3382
6653
6652
0
0
3381
41
3380
3379
3378
3377
3376
3375
3374
3373
6651
40
39
38
37
0
36
35
34
33
32
31
30
29
28
27
26
25
24
23
22
21
3372
3371...

result:

ok q=100000

Test #133:

score: 0
Accepted
time: 122ms
memory: 5036kb

input:

9970 100000
3 1
1 5
1 9
1 13
17 1
21 1
25 1
1 29
33 1
1 37
1 41
45 1
49 1
53 1
57 1
61 1
65 1
1 69
1 73
1 77
1 81
85 1
1 89
93 1
97 1
101 1
105 1
1 109
113 1
117 1
121 1
125 1
1 129
133 1
1 137
1 141
1 145
149 1
1 153
157 1
1 161
1 165
1 169
1 173
1 177
181 1
185 1
189 1
193 1
1 197
201 1
1 205
209 ...

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 #134:

score: 0
Accepted
time: 124ms
memory: 5200kb

input:

9970 100000
1 2
1 3
1 5
9 1
1 13
1 17
1 21
1 25
29 1
1 33
37 1
1 41
45 1
1 49
1 53
1 57
1 61
65 1
69 1
73 1
1 77
1 81
1 85
1 89
1 93
1 97
101 1
105 1
109 1
1 113
1 117
121 1
125 1
1 129
1 133
137 1
1 141
145 1
1 149
153 1
1 157
1 161
1 165
169 1
173 1
1 177
1 181
1 185
1 189
193 1
1 197
1 201
205 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
2
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
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 #135:

score: 0
Accepted
time: 107ms
memory: 5152kb

input:

9970 100000
1 2
1 5
9 1
13 1
17 1
1 21
25 1
1 29
33 1
1 37
41 1
1 45
1 49
1 53
1 57
61 1
65 1
69 1
73 1
77 1
1 81
85 1
89 1
93 1
1 97
101 1
1 105
1 109
1 113
1 117
1 121
1 125
129 1
1 133
1 137
1 141
1 145
1 149
153 1
1 157
1 161
165 1
169 1
1 173
177 1
181 1
1 185
189 1
193 1
197 1
1 201
205 1
1 20...

output:

2494
64
63
62
61
60
59
58
57
56
1
2496
2560
2559
55
54
53
52
2495
4992
4991
0
4990
2558
51
50
49
2557
2556
2555
4989
4988
7488
2554
7487
48
7486
0
5056
5055
5054
5053
2553
2552
2551
47
2550
5052
5051
2549
2548
2547
2546
2545
2544
2543
2542
2541
2540
5050
46
45
44
43
42
41
40
39
38
37
36
35
34
33
32
...

result:

ok q=100000

Test #136:

score: 0
Accepted
time: 495ms
memory: 5280kb

input:

9970 100000
1 3
5 1
9 1
13 1
1 17
21 1
25 1
1 29
33 1
1 37
1 41
1 45
1 49
53 1
57 1
61 1
65 1
69 1
73 1
77 1
1 81
85 1
1 89
1 93
1 97
1 101
105 1
109 1
113 1
1 117
1 121
1 125
129 1
1 133
137 1
141 1
145 1
1 149
153 1
157 1
1 161
1 165
1 169
1 173
1 177
181 1
1 185
1 189
193 1
1 197
1 201
1 205
1 20...

output:

0
0
0
0
4987
7488
1
2494
4992
4991
7487
2496
2495
2560
64
63
62
61
60
59
58
7486
4990
4989
4988
7485
7484
5056
5055
7483
5054
5053
7482
7481
57
7480
5052
56
55
54
2559
2558
2557
53
52
51
50
49
48
47
0
0
5051
5050
5049
5048
5047
0
0
0
46
45
44
43
42
41
40
39
38
37
36
35
34
5046
5045
5044
33
32
31
30
...

result:

ok q=100000

Test #137:

score: 0
Accepted
time: 121ms
memory: 4900kb

input:

9970 100000
3 1
4 1
1 5
6 1
11 1
1 16
1 21
1 26
1 31
36 1
41 1
1 46
1 51
1 56
61 1
66 1
1 71
76 1
81 1
86 1
91 1
1 96
101 1
106 1
111 1
1 116
1 121
1 126
131 1
136 1
1 141
146 1
151 1
156 1
1 161
1 166
171 1
176 1
181 1
186 1
1 191
196 1
201 1
206 1
211 1
216 1
221 1
226 1
231 1
1 236
1 241
1 246
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 #138:

score: 0
Accepted
time: 134ms
memory: 4992kb

input:

9970 100000
3 1
6 1
11 1
1 16
1 21
26 1
1 31
1 36
1 41
46 1
51 1
56 1
61 1
1 66
1 71
1 76
81 1
86 1
1 91
96 1
1 101
1 106
1 111
116 1
1 121
126 1
131 1
1 136
141 1
1 146
151 1
156 1
161 1
166 1
1 171
176 1
1 181
186 1
1 191
196 1
1 201
206 1
1 211
1 216
1 221
1 226
1 231
1 236
241 1
1 246
251 1
1 25...

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 #139:

score: 0
Accepted
time: 106ms
memory: 5236kb

input:

9970 100000
1 2
1 6
11 1
16 1
1 21
26 1
31 1
1 36
41 1
46 1
51 1
56 1
1 61
66 1
1 71
1 76
81 1
1 86
91 1
1 96
1 101
106 1
111 1
116 1
121 1
126 1
1 131
1 136
141 1
1 146
151 1
156 1
161 1
166 1
171 1
176 1
181 1
186 1
191 1
1 196
1 201
206 1
1 211
1 216
1 221
1 226
1 231
1 236
241 1
246 1
1 251
256 ...

output:

1995
0
1996
3990
5984
4032
4031
4030
64
4029
63
62
61
60
59
4028
4027
58
57
56
55
54
1
2048
2047
2046
4026
4025
53
52
51
4024
6016
0
50
0
8000
2045
49
48
47
46
45
44
6015
0
43
0
2044
2043
2042
42
41
40
39
4023
4022
2041
38
37
36
35
34
33
32
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
20...

result:

ok q=100000

Test #140:

score: 0
Accepted
time: 491ms
memory: 5124kb

input:

9970 100000
1 2
3 1
6 1
1 11
1 16
1 21
1 26
31 1
36 1
41 1
1 46
51 1
56 1
1 61
1 66
71 1
1 76
81 1
86 1
91 1
96 1
1 101
106 1
111 1
116 1
121 1
126 1
131 1
136 1
1 141
1 146
151 1
1 156
1 161
1 166
1 171
1 176
1 181
1 186
191 1
1 196
201 1
206 1
1 211
216 1
221 1
226 1
231 1
1 236
1 241
1 246
251 1
...

output:

0
6016
6015
6014
6013
6012
6011
1
6010
6009
6008
6007
2048
2047
2046
2045
2044
2043
2042
2041
2040
6006
6005
6004
64
63
62
61
60
59
58
57
56
55
54
53
52
51
50
49
48
47
46
45
44
43
42
41
40
39
38
37
36
35
34
33
32
31
30
29
28
27
26
25
24
23
22
21
2039
2038
2
2037
2036
2035
2034
2033
2032
2031
2030
20...

result:

ok q=100000

Test #141:

score: 0
Accepted
time: 124ms
memory: 5052kb

input:

9970 100000
2 1
1 6
1 7
13 1
19 1
1 25
1 31
1 37
1 43
1 49
1 55
1 61
1 67
73 1
79 1
1 85
91 1
1 97
103 1
109 1
115 1
121 1
127 1
1 133
1 139
145 1
151 1
157 1
1 163
1 169
175 1
181 1
187 1
1 193
199 1
1 205
1 211
1 217
223 1
1 229
1 235
241 1
247 1
253 1
1 259
1 265
271 1
277 1
1 283
289 1
1 295
301...

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
3327
4991
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
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 #142:

score: 0
Accepted
time: 117ms
memory: 5056kb

input:

9970 100000
2 1
1 3
4 1
1 6
7 1
1 13
1 19
1 25
1 31
1 37
43 1
1 49
1 55
61 1
67 1
1 73
79 1
85 1
1 91
1 97
1 103
109 1
115 1
121 1
1 127
133 1
1 139
145 1
1 151
157 1
163 1
1 169
175 1
181 1
187 1
193 1
1 199
205 1
1 211
217 1
223 1
229 1
1 235
241 1
1 247
1 253
259 1
265 1
271 1
1 277
1 283
289 1
2...

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 #143:

score: 0
Accepted
time: 113ms
memory: 5124kb

input:

9970 100000
4 1
1 5
6 1
7 1
1 13
1 19
25 1
31 1
37 1
1 43
49 1
55 1
61 1
67 1
1 73
1 79
85 1
1 91
97 1
103 1
1 109
1 115
121 1
1 127
133 1
1 139
1 145
151 1
1 157
163 1
1 169
175 1
181 1
187 1
1 193
1 199
1 205
211 1
1 217
1 223
229 1
235 1
1 241
247 1
253 1
1 259
265 1
1 271
1 277
1 283
1 289
1 295...

output:

2
0
1728
3
1727
64
63
62
1
1726
1725
1724
61
60
59
58
57
56
55
54
53
52
51
50
49
48
47
46
45
44
43
42
1667
1666
1665
3392
4992
3391
4991
3390
3389
4990
41
40
6652
3388
39
38
37
36
35
1723
3387
34
33
3386
3385
5056
3384
5055
5054
1722
1721
1720
32
31
30
29
28
27
26
25
24
5053
1719
1718
1717
1716
1715...

result:

ok q=100000

Test #144:

score: 0
Accepted
time: 505ms
memory: 5072kb

input:

9970 100000
3 1
1 4
5 1
1 7
13 1
19 1
1 25
1 31
37 1
43 1
1 49
55 1
61 1
67 1
73 1
79 1
1 85
1 91
1 97
1 103
109 1
1 115
1 121
1 127
1 133
139 1
1 145
151 1
1 157
163 1
1 169
175 1
181 1
187 1
1 193
199 1
205 1
211 1
217 1
1 223
1 229
235 1
1 241
1 247
1 253
259 1
1 265
271 1
1 277
283 1
1 289
295 1...

output:

64
63
62
61
60
59
58
57
56
55
54
53
52
51
50
49
48
47
46
45
3
1
44
43
42
41
40
39
38
37
36
35
34
33
32
31
2
1665
3328
6652
3327
1728
4990
6656
6655
4992
4991
5056
5055
3392
3391
3390
3389
3388
3387
3386
3385
3384
30
3383
3382
3381
3380
3379
3378
3377
3376
3375
5054
8320
8319
8318
6654
6653
3374
1727...

result:

ok q=100000

Test #145:

score: 0
Accepted
time: 128ms
memory: 6072kb

input:

9970 100000
3 1
6 1
1 7
1 8
15 1
1 22
29 1
1 36
43 1
1 50
1 57
1 64
71 1
1 78
1 85
92 1
1 99
1 106
1 113
1 120
1 127
1 134
141 1
148 1
1 155
162 1
169 1
176 1
183 1
190 1
197 1
204 1
211 1
1 218
225 1
1 232
239 1
246 1
1 253
1 260
1 267
1 274
281 1
1 288
1 295
302 1
309 1
1 316
1 323
330 1
1 337
344...

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 #146:

score: 0
Accepted
time: 120ms
memory: 5128kb

input:

9970 100000
1 3
5 1
6 1
1 8
15 1
22 1
29 1
36 1
1 43
50 1
57 1
64 1
1 71
1 78
1 85
92 1
99 1
106 1
113 1
1 120
127 1
134 1
141 1
1 148
1 155
1 162
169 1
1 176
1 183
1 190
197 1
1 204
1 211
218 1
1 225
1 232
1 239
1 246
253 1
1 260
1 267
274 1
1 281
288 1
1 295
302 1
1 309
1 316
1 323
1 330
1 337
344...

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
1430
2856
7128
0
0
0
0
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 #147:

score: 0
Accepted
time: 112ms
memory: 6072kb

input:

9970 100000
3 1
4 1
6 1
8 1
1 15
1 22
1 29
36 1
43 1
50 1
1 57
64 1
1 71
78 1
1 85
1 92
99 1
106 1
113 1
120 1
127 1
134 1
1 141
1 148
155 1
162 1
1 169
1 176
183 1
1 190
197 1
1 204
1 211
218 1
1 225
232 1
1 239
1 246
1 253
260 1
267 1
1 274
1 281
288 1
1 295
1 302
1 309
1 316
323 1
1 330
1 337
1 3...

output:

1472
64
63
62
61
60
59
3
2
1428
1
1430
58
57
56
55
54
2855
1429
1471
1470
1469
1468
2880
2879
2878
53
52
51
0
50
49
5703
1467
48
47
46
2877
45
44
43
42
41
40
39
38
37
36
35
1466
1465
1464
1463
1462
4288
4279
2876
34
33
5760
4287
4286
7168
1461
1460
32
31
30
29
28
2875
2874
5759
5704
7167
0
4285
4284...

result:

ok q=100000

Test #148:

score: 0
Accepted
time: 491ms
memory: 5976kb

input:

9970 100000
3 1
5 1
1 8
15 1
1 22
1 29
36 1
43 1
50 1
57 1
64 1
1 71
1 78
85 1
1 92
1 99
106 1
1 113
120 1
127 1
1 134
141 1
1 148
155 1
1 162
169 1
176 1
1 183
190 1
197 1
1 204
211 1
218 1
225 1
1 232
239 1
1 246
253 1
260 1
1 267
274 1
1 281
288 1
295 1
1 302
1 309
316 1
323 1
330 1
337 1
344 1
3...

output:

0
0
2855
1
1472
1471
1470
1469
64
63
62
61
60
59
58
57
56
55
54
53
1468
1467
1466
1465
1464
4281
5705
8576
1463
1462
1461
1460
1459
2
1458
1457
1456
1455
1454
1453
1452
1451
1450
1449
1448
1447
1446
1445
1444
1443
1442
1441
1440
1439
1428
1427
2880
2879
2878
2877
1429
2876
2875
2874
4279
1438
1437
1...

result:

ok q=100000

Test #149:

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

input:

9970 100000
2 1
1 3
1 4
5 1
7 1
8 1
1 9
1 17
25 1
1 33
1 41
1 49
1 57
1 65
73 1
1 81
1 89
1 97
1 105
1 113
121 1
1 129
137 1
145 1
1 153
161 1
169 1
177 1
1 185
193 1
201 1
209 1
1 217
1 225
233 1
241 1
1 249
257 1
265 1
1 273
1 281
289 1
297 1
305 1
1 313
321 1
329 1
1 337
345 1
353 1
1 361
1 369
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 #150:

score: 0
Accepted
time: 129ms
memory: 5264kb

input:

9970 100000
1 4
1 5
6 1
8 1
9 1
17 1
25 1
1 33
1 41
1 49
57 1
65 1
1 73
81 1
89 1
97 1
105 1
1 113
121 1
1 129
137 1
145 1
1 153
1 161
1 169
177 1
1 185
1 193
1 201
209 1
217 1
1 225
233 1
1 241
249 1
257 1
265 1
1 273
1 281
289 1
1 297
305 1
1 313
321 1
1 329
1 337
345 1
1 353
361 1
369 1
377 1
385...

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
4
1254
7486
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
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 #151:

score: 0
Accepted
time: 122ms
memory: 5116kb

input:

9970 100000
1 3
1 6
8 1
1 9
17 1
25 1
33 1
1 41
1 49
57 1
65 1
73 1
81 1
89 1
1 97
105 1
113 1
121 1
1 129
1 137
1 145
1 153
161 1
169 1
177 1
1 185
193 1
1 201
209 1
1 217
1 225
233 1
1 241
249 1
257 1
265 1
1 273
281 1
289 1
1 297
1 305
1 313
1 321
1 329
1 337
345 1
353 1
1 361
1 369
1 377
385 1
1...

output:

1
1250
2560
2
2559
2558
2557
2556
3
1252
2555
2501
2499
3748
3776
1280
1279
3775
1251
1278
64
63
62
61
60
59
58
57
56
55
54
53
52
1277
1276
1275
51
50
49
48
47
46
45
44
43
42
41
40
39
3774
38
37
36
35
34
33
32
31
30
1274
1273
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
1272
1271
12
11
1270
12...

result:

ok q=100000

Test #152:

score: 0
Accepted
time: 490ms
memory: 5092kb

input:

9970 100000
2 1
1 3
5 1
1 9
17 1
25 1
1 33
41 1
1 49
1 57
65 1
73 1
81 1
89 1
1 97
105 1
1 113
121 1
1 129
1 137
145 1
153 1
1 161
1 169
1 177
185 1
193 1
201 1
1 209
1 217
225 1
1 233
241 1
249 1
257 1
265 1
1 273
1 281
1 289
297 1
1 305
1 313
1 321
1 329
337 1
345 1
353 1
1 361
1 369
377 1
1 385
1...

output:

0
0
3776
1252
3747
6272
6271
64
63
6270
6269
6268
6267
6266
2500
2
1250
2560
2559
3748
4995
4994
6265
62
61
60
59
58
57
56
55
54
53
52
51
50
49
48
47
46
3
1251
2499
3746
2558
2557
2556
2555
3775
45
44
43
42
41
40
39
38
37
36
35
34
33
32
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
1
1280
1279
1278
1...

result:

ok q=100000

Test #153:

score: 0
Accepted
time: 84ms
memory: 5136kb

input:

1000 100000
1 5
17 1
22 1
33 1
1 34
35 1
41 1
1 55
1 56
60 1
75 1
76 1
1 77
88 1
1 89
1 93
1 95
1 96
97 1
98 1
1 103
1 105
108 1
1 112
1 115
116 1
143 1
1 147
156 1
164 1
1 168
183 1
188 1
197 1
198 1
199 1
210 1
1 213
215 1
1 217
223 1
224 1
225 1
228 1
1 233
236 1
240 1
249 1
250 1
258 1
259 1
1 2...

output:

63

result:

ok q=100000

Test #154:

score: 0
Accepted
time: 253ms
memory: 5400kb

input:

1000 100000
1 10
1 16
21 1
23 1
1 28
30 1
1 31
1 36
39 1
1 44
1 45
1 48
1 57
61 1
62 1
1 63
67 1
69 1
77 1
1 78
1 84
1 91
94 1
96 1
1 100
1 104
112 1
115 1
1 120
1 124
128 1
130 1
137 1
148 1
1 161
164 1
170 1
1 173
1 185
188 1
189 1
1 192
1 195
1 200
207 1
1 210
1 219
230 1
237 1
239 1
245 1
247 1
...

output:

64
54
24
101
10
176
120
87
168
166
124
75
32
104
59
41
11
114
7
63
62
61
39
110
100
98
14
93
91
82
30
33
15
3
45
49
35
22
4
105
23
96
50
46
116
77
73
68
95
127
118
79
186
180
42
111
177
174
112
172
169
164
187
92
70
126
159
156
155
125
154
191
163
157
153
152
151
150
149
56
135
123
133
252
251
103
8...

result:

ok q=100000

Test #155:

score: 0
Accepted
time: 478ms
memory: 5344kb

input:

1000 100000
1 10
1 13
14 1
16 1
1 19
21 1
32 1
1 39
40 1
1 44
49 1
1 51
52 1
1 54
1 56
61 1
63 1
70 1
1 73
1 83
1 87
1 99
101 1
104 1
111 1
114 1
119 1
121 1
122 1
126 1
1 130
133 1
135 1
1 146
150 1
158 1
170 1
183 1
1 184
185 1
186 1
187 1
1 190
192 1
196 1
205 1
208 1
223 1
227 1
1 235
1 242
244 ...

output:

740
693
67
654
101
460
519
325
17
536
736
795
774
33
186
368
671
493
62
165
137
95
209
412
85
222
150
258
400
115
65
157
252
118
226
501
409
114
120
131
449
609
296
247
316
498
608
66
40
248
365
331
35
103
462
459
630
406
414
266
482
160
430
47
5
130
211
193
640
639
638
637
636
635
433
634
633
632
6...

result:

ok q=100000

Test #156:

score: 0
Accepted
time: 646ms
memory: 5348kb

input:

1000 100000
1 2
3 1
5 1
1 8
9 1
10 1
1 11
19 1
21 1
42 1
44 1
45 1
1 46
1 67
69 1
1 75
1 87
1 88
100 1
103 1
114 1
121 1
1 123
127 1
131 1
1 143
1 149
151 1
153 1
159 1
1 163
1 174
176 1
1 185
1 186
191 1
1 194
1 205
210 1
1 215
1 217
1 219
1 220
222 1
1 229
232 1
234 1
1 237
240 1
1 241
245 1
1 247...

output:

0
0
0
0
0
0
0
686
186
20
228
4
240
33
335
419
408
190
395
387
453
532
617
116
355
643
767
713
828
6
420
608
754
781
62
862
441
467
657
829
510
715
956
34
945
927
151
141
344
204
280
380
540
515
174
318
557
624
620
603
768
709
845
249
886
957
291
881
92
295
559
696
595
670
2
358
448
447
32
369
136
73...

result:

ok q=100000

Test #157:

score: 0
Accepted
time: 588ms
memory: 5348kb

input:

1000 100000
1 6
1 12
18 1
19 1
34 1
1 37
41 1
53 1
58 1
1 63
1 66
1 70
73 1
1 80
1 82
94 1
1 104
1 110
1 112
1 114
1 115
118 1
121 1
126 1
131 1
136 1
1 137
139 1
1 145
146 1
148 1
1 149
1 159
1 161
164 1
170 1
186 1
189 1
191 1
193 1
1 197
1 206
207 1
208 1
212 1
224 1
1 225
1 226
228 1
229 1
233 1...

output:

478
570
373
1020
1458
1576
239
1489
1680
1831
329
179
751
83
1165
1158
1464
1569
1712
1822
758
823
801
1005
999
983
299
1248
1236
201
390
1295
1385
1445
1433
1431
1631
1777
546
732
1127
1600
738
1772
272
469
531
711
706
841
1265
1716
1729
1845
1800
1916
1890
1976
1973
1962
1943
2035
214
170
409
462
...

result:

ok q=100000

Test #158:

score: 0
Accepted
time: 370ms
memory: 5564kb

input:

1000 100000
1 10
1 20
23 1
26 1
32 1
35 1
1 41
47 1
1 52
1 54
57 1
1 58
61 1
68 1
71 1
1 82
1 85
90 1
103 1
1 114
1 124
125 1
129 1
1 133
1 135
139 1
140 1
1 143
1 158
1 160
1 161
164 1
1 169
174 1
181 1
186 1
187 1
188 1
189 1
199 1
1 208
1 227
1 228
1 232
1 240
1 243
250 1
1 255
260 1
270 1
272 1
...

output:

0
0
157
2131
4522
6322
7500
8680
372
700
769
1157
1902
2475
2539
4672
4738
1308
1896
4269
4881
5093
5152
2652
5649
5938
6058
6669
7273
7424
7513
965
1364
1765
2352
2951
3316
821
1016
1217
2006
3583
3730
3943
3540
2251
3414
3634
3995
4178
4638
153
746
946
2938
3127
3713
4797
4755
5391
5522
5593
5638
...

result:

ok q=100000

Test #159:

score: 0
Accepted
time: 112ms
memory: 5864kb

input:

1000 100000
5 1
1 11
1 20
1 37
43 1
44 1
47 1
48 1
54 1
1 63
69 1
1 70
72 1
73 1
83 1
84 1
1 86
1 93
1 94
1 95
1 101
1 108
114 1
115 1
124 1
137 1
1 141
1 144
1 151
158 1
159 1
160 1
167 1
175 1
181 1
1 183
1 191
1 196
1 198
1 203
1 213
1 215
216 1
239 1
245 1
246 1
249 1
1 254
261 1
264 1
277 1
289...

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 #160:

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

input:

1000 100000
2 1
15 1
1 18
21 1
1 23
33 1
52 1
54 1
55 1
1 56
1 57
1 61
62 1
1 66
69 1
1 72
1 73
1 75
79 1
1 85
87 1
1 88
1 89
95 1
104 1
121 1
1 123
1 127
1 131
1 135
1 136
137 1
1 139
1 148
150 1
1 156
1 162
1 189
192 1
193 1
1 194
1 197
1 209
1 213
1 216
1 218
220 1
221 1
222 1
1 230
248 1
1 249
1...

output:

64

result:

ok q=100000

Test #161:

score: 0
Accepted
time: 256ms
memory: 5376kb

input:

1000 100000
5 1
11 1
1 15
23 1
25 1
1 26
1 27
1 30
35 1
39 1
1 49
1 53
1 57
1 72
1 73
1 78
1 81
83 1
1 85
1 87
88 1
96 1
101 1
1 107
110 1
1 112
116 1
118 1
1 121
1 123
124 1
125 1
131 1
134 1
1 137
1 140
141 1
143 1
155 1
1 157
1 168
171 1
177 1
182 1
184 1
185 1
1 187
193 1
1 206
207 1
1 208
209 1...

output:

64
63
60
59
57
52
51
49
48
47
46
44
43
41
40
39
29
26
23
21
20
19
16
15
13
12
10
8
7
5
4
3
14
128
61
54
25
126
125
123
121
116
112
111
110
109
119
108
107
103
102
99
98
97
95
90
87
85
82
62
28
118
94
32
75
72
122
70
69
66
11
67
65
191
190
189
101
187
185
183
181
179
178
175
170
30
6
104
169
167
165
...

result:

ok q=100000

Test #162:

score: 0
Accepted
time: 481ms
memory: 5372kb

input:

1000 100000
1 6
7 1
1 12
1 22
1 25
1 29
1 31
36 1
45 1
1 67
75 1
1 81
85 1
1 89
95 1
97 1
1 103
115 1
123 1
125 1
1 129
133 1
137 1
148 1
1 155
158 1
178 1
179 1
1 181
1 187
1 188
205 1
207 1
208 1
1 211
1 214
1 219
1 223
231 1
1 237
239 1
1 242
243 1
251 1
256 1
1 260
262 1
269 1
270 1
271 1
275 1
...

output:

64
62
61
60
59
58
55
54
53
52
51
50
49
47
44
43
41
39
38
37
35
33
32
31
30
27
26
24
22
63
57
56
48
46
45
42
40
36
34
28
25
23
21
18
11
7
6
2
128
127
122
121
10
120
118
117
115
114
112
111
110
109
106
101
100
124
99
98
108
96
95
94
91
90
86
85
84
81
78
75
70
69
29
67
65
192
14
191
186
183
181
180
179...

result:

ok q=100000

Test #163:

score: 0
Accepted
time: 643ms
memory: 5392kb

input:

1000 100000
3 1
8 1
9 1
1 16
28 1
45 1
1 49
1 55
1 56
57 1
66 1
68 1
1 70
1 74
78 1
1 84
1 85
86 1
87 1
97 1
99 1
103 1
105 1
1 107
1 111
1 112
1 127
130 1
1 133
1 134
142 1
143 1
149 1
161 1
167 1
1 168
172 1
1 174
1 179
1 190
193 1
1 195
1 202
205 1
1 209
216 1
217 1
218 1
1 219
1 229
1 234
236 1
...

output:

61
59
57
56
55
52
49
47
42
41
40
39
38
37
36
31
29
28
22
21
17
14
12
10
27
9
8
7
6
5
4
3
128
127
126
124
119
115
114
113
111
110
109
117
108
107
103
102
101
99
96
94
91
88
87
84
83
79
78
77
73
71
68
66
192
190
187
186
185
183
182
75
180
178
177
176
175
174
173
171
168
167
166
165
163
162
161
159
155...

result:

ok q=100000

Test #164:

score: 0
Accepted
time: 571ms
memory: 5380kb

input:

1000 100000
1 13
16 1
17 1
1 22
1 24
29 1
1 30
1 55
57 1
1 58
59 1
1 72
73 1
75 1
77 1
1 85
87 1
1 89
90 1
1 93
1 99
101 1
1 103
1 106
1 119
1 122
125 1
145 1
1 151
1 158
1 163
1 167
170 1
179 1
184 1
1 187
1 193
1 201
202 1
204 1
1 207
1 211
213 1
216 1
222 1
224 1
226 1
234 1
1 242
246 1
259 1
1 2...

output:

61
59
58
57
56
53
52
51
48
47
43
42
41
38
37
34
30
23
22
15
13
12
10
9
8
7
6
4
3
2
128
118
116
112
110
109
101
99
97
96
95
94
90
84
83
82
81
80
79
78
77
75
74
73
72
71
70
69
68
67
66
65
192
190
189
187
100
186
185
184
181
179
28
174
173
172
169
166
163
160
158
154
162
151
149
147
145
142
137
134
132...

result:

ok q=100000

Test #165:

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

input:

1000 100000
2 1
3 1
9 1
11 1
22 1
1 33
1 39
1 42
1 43
1 44
1 49
67 1
68 1
73 1
76 1
78 1
81 1
1 84
85 1
87 1
88 1
1 93
1 99
108 1
128 1
1 129
1 132
134 1
135 1
138 1
1 142
144 1
1 150
1 155
158 1
160 1
1 170
1 175
183 1
1 193
1 197
213 1
1 215
216 1
222 1
1 225
1 233
234 1
235 1
242 1
258 1
268 1
1 ...

output:

56
51
50
47
43
42
41
38
36
35
33
29
27
26
25
22
21
20
19
17
13
10
64
8
5
1
125
121
119
117
113
110
109
108
103
102
101
100
99
95
94
89
88
86
84
80
79
78
76
74
73
72
71
70
69
67
66
192
191
189
185
184
183
180
179
177
176
174
173
172
171
167
165
163
162
160
159
157
154
153
152
148
145
136
135
140
134
...

result:

ok q=100000

Test #166:

score: 0
Accepted
time: 118ms
memory: 5856kb

input:

1000 100000
13 1
22 1
1 24
1 29
32 1
42 1
46 1
50 1
1 56
1 62
66 1
1 68
1 69
71 1
1 73
1 75
81 1
1 87
88 1
94 1
1 96
101 1
107 1
1 108
110 1
111 1
126 1
1 143
148 1
1 150
160 1
166 1
176 1
1 180
1 183
1 195
1 206
211 1
1 213
1 216
219 1
236 1
1 238
1 242
1 249
251 1
252 1
256 1
266 1
1 277
1 293
295...

output:

64
63
62
61
58
56
55
51
47
46
43
38
37
35
33
32
30
29
28
27
25
23
22
21
19
17
15
14
9
7
126
124
122
121
120
119
118
117
116
114
109
108
107
104
103
102
100
99
98
96
95
91
88
87
86
81
79
78
77
75
74
73
70
68
66
65
192
189
183
182
181
179
177
176
172
171
170
166
164
163
162
155
154
151
150
146
143
141...

result:

ok q=100000

Test #167:

score: 0
Accepted
time: 84ms
memory: 5016kb

input:

1000 100000
1 4
1 7
8 1
14 1
16 1
1 17
20 1
22 1
1 28
1 29
34 1
1 35
1 38
1 41
1 49
1 53
1 57
1 58
1 74
1 84
85 1
1 90
95 1
103 1
104 1
1 107
108 1
110 1
1 117
1 118
1 126
1 141
142 1
1 145
1 147
1 152
153 1
154 1
1 163
1 165
166 1
173 1
175 1
180 1
1 184
188 1
1 189
194 1
201 1
204 1
207 1
1 210
21...

output:

63

result:

ok q=100000

Test #168:

score: 0
Accepted
time: 254ms
memory: 6060kb

input:

1000 100000
15 1
18 1
1 26
31 1
1 37
1 40
42 1
1 46
1 48
1 49
1 53
55 1
1 68
75 1
82 1
83 1
89 1
92 1
102 1
106 1
1 113
1 114
1 119
1 121
1 123
128 1
129 1
130 1
1 133
140 1
1 143
1 153
1 154
1 163
1 167
168 1
171 1
176 1
178 1
1 190
191 1
1 192
1 200
201 1
204 1
205 1
1 206
212 1
1 215
1 218
1 223
...

output:

185
49
45
23
22
88
107
89
65
191
92
181
178
177
72
40
46
173
162
159
182
59
123
119
156
144
30
71
87
95
176
126
1
82
15
187
155
146
12
85
137
133
143
127
20
52
110
73
47
34
189
170
44
101
51
175
154
19
140
129
254
252
251
58
54
106
102
96
166
164
61
42
63
150
243
240
14
255
21
121
99
81
235
231
229
...

result:

ok q=100000

Test #169:

score: 0
Accepted
time: 481ms
memory: 5400kb

input:

1000 100000
5 1
14 1
1 17
33 1
40 1
55 1
1 58
59 1
1 61
1 66
70 1
1 71
1 75
76 1
79 1
1 81
90 1
95 1
1 102
1 104
1 109
119 1
130 1
1 131
142 1
144 1
147 1
1 154
158 1
1 161
170 1
178 1
1 182
187 1
189 1
1 211
217 1
1 229
1 233
245 1
248 1
1 249
254 1
256 1
1 257
258 1
271 1
1 273
1 277
286 1
1 287
1...

output:

0
0
16
44
129
231
193
61
314
312
77
305
270
173
283
209
4
371
329
163
206
184
355
271
323
93
83
180
220
60
47
165
237
42
130
284
258
360
281
325
343
328
436
396
388
99
48
439
498
171
156
368
425
54
39
13
7
3
111
182
167
35
290
362
361
103
298
308
18
56
124
88
160
279
63
262
267
50
381
172
95
370
352...

result:

ok q=100000

Test #170:

score: 0
Accepted
time: 649ms
memory: 5464kb

input:

1000 100000
1 5
1 13
1 19
26 1
1 29
34 1
35 1
38 1
39 1
45 1
1 46
1 67
79 1
1 92
94 1
1 97
108 1
1 111
1 120
122 1
1 129
131 1
140 1
1 143
148 1
159 1
1 169
175 1
180 1
185 1
187 1
1 189
1 192
1 195
200 1
205 1
1 208
1 213
1 228
1 232
243 1
244 1
1 245
1 246
1 263
271 1
274 1
1 281
292 1
299 1
301 1...

output:

0
75
208
39
294
378
112
317
69
425
491
309
119
457
526
584
522
277
421
675
167
238
106
234
267
477
513
646
403
621
724
711
705
260
470
806
790
877
869
852
851
834
919
181
585
909
632
672
136
827
870
906
1021
1086
1072
1046
1045
1039
1031
1147
1143
1131
217
616
153
412
484
614
52
244
298
33
126
223
2...

result:

ok q=100000

Test #171:

score: 0
Accepted
time: 576ms
memory: 5380kb

input:

1000 100000
1 3
4 1
1 5
8 1
1 11
1 21
1 24
1 27
36 1
45 1
1 51
1 74
1 75
79 1
1 80
83 1
1 86
1 93
1 95
98 1
101 1
106 1
109 1
110 1
117 1
127 1
1 130
1 131
1 137
1 141
145 1
1 154
155 1
160 1
1 164
166 1
168 1
169 1
172 1
1 173
174 1
181 1
1 185
1 188
198 1
1 202
1 212
217 1
1 228
230 1
1 234
1 235
...

output:

0
0
1393
2599
561
125
216
143
405
500
733
887
944
973
196
1170
704
169
444
934
18
966
228
1166
1327
1359
1556
1725
624
284
1024
1042
424
992
1192
1443
1619
139
526
907
1267
1756
1858
378
90
1051
1252
1828
1948
1927
2010
212
787
1370
2008
2159
238
27
430
805
1766
1975
1974
647
316
509
1005
1206
1176
...

result:

ok q=100000

Test #172:

score: 0
Accepted
time: 359ms
memory: 5396kb

input:

1000 100000
4 1
1 6
8 1
1 9
12 1
16 1
1 20
1 32
50 1
1 62
70 1
1 72
1 74
1 77
78 1
1 79
1 84
88 1
89 1
94 1
95 1
1 97
107 1
114 1
1 115
126 1
130 1
132 1
1 138
1 144
1 156
1 162
1 163
165 1
178 1
1 181
1 185
1 192
200 1
214 1
1 215
1 218
1 221
1 226
1 232
1 235
1 237
246 1
1 249
1 256
1 269
279 1
28...

output:

0
0
0
0
0
1357
793
1765
2163
1467
1536
2194
2177
2801
2991
3089
3364
3603
3795
4168
510
715
1099
274
1298
1501
1011
1912
1875
2888
3020
3127
596
1590
1782
1995
2802
3333
3488
349
1141
1734
3378
3707
3873
4309
4362
104
1911
3126
4096
509
782
1165
1573
1754
2709
3184
3578
3975
4094
4161
4281
237
489
5...

result:

ok q=100000

Test #173:

score: 0
Accepted
time: 123ms
memory: 5668kb

input:

1000 100000
4 1
7 1
10 1
1 11
1 15
19 1
20 1
25 1
1 37
40 1
41 1
1 45
1 49
1 55
62 1
67 1
68 1
1 70
1 84
1 87
98 1
102 1
1 122
1 131
141 1
1 148
149 1
1 150
1 155
1 165
1 171
1 179
183 1
185 1
1 189
191 1
1 193
201 1
1 205
217 1
218 1
219 1
1 237
1 240
1 251
257 1
261 1
268 1
274 1
1 285
286 1
1 289...

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 #174:

score: 0
Accepted
time: 97ms
memory: 4884kb

input:

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

score: 0
Accepted
time: 104ms
memory: 6044kb

input:

970 100000
1 2
3 1
1 4
1 5
6 1
1 7
8 1
1 9
10 1
1 11
12 1
13 1
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
27 1
28 1
1 29
1 30
31 1
1 32
1 33
34 1
1 35
36 1
37 1
38 1
39 1
40 1
41 1
42 1
1 43
44 1
1 45
46 1
1 47
48 1
49 1
1 50
1 51
1 52
1 53
54 1
55 1
1 56
1 57
1 58
1 59
60 1
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 #176:

score: 0
Accepted
time: 102ms
memory: 5008kb

input:

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

output:

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

result:

ok q=100000

Test #177:

score: 0
Accepted
time: 487ms
memory: 4972kb

input:

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

output:

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

result:

ok q=100000

Test #178:

score: 0
Accepted
time: 103ms
memory: 4964kb

input:

970 100000
2 1
3 1
1 5
1 7
1 9
11 1
1 13
15 1
1 17
19 1
1 21
23 1
1 25
1 27
29 1
31 1
1 33
35 1
37 1
39 1
1 41
1 43
1 45
1 47
1 49
51 1
1 53
55 1
1 57
59 1
61 1
63 1
1 65
67 1
1 69
1 71
73 1
75 1
77 1
79 1
1 81
83 1
1 85
1 87
89 1
91 1
93 1
1 95
1 97
1 99
101 1
1 103
1 105
1 107
1 109
1 111
113 1
11...

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
1
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok q=100000

Test #179:

score: 0
Accepted
time: 94ms
memory: 4984kb

input:

970 100000
2 1
1 3
1 5
7 1
1 9
11 1
13 1
1 15
17 1
1 19
1 21
23 1
1 25
27 1
29 1
31 1
1 33
1 35
1 37
1 39
1 41
1 43
1 45
47 1
1 49
1 51
1 53
55 1
57 1
59 1
61 1
63 1
1 65
1 67
1 69
1 71
1 73
1 75
77 1
79 1
1 81
83 1
1 85
87 1
89 1
1 91
1 93
1 95
97 1
99 1
1 101
1 103
1 105
107 1
109 1
111 1
113 1
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 #180:

score: 0
Accepted
time: 110ms
memory: 5836kb

input:

970 100000
1 2
3 1
1 5
7 1
9 1
11 1
13 1
15 1
17 1
1 19
21 1
1 23
1 25
1 27
1 29
1 31
33 1
35 1
37 1
1 39
1 41
43 1
1 45
1 47
49 1
51 1
1 53
55 1
57 1
1 59
1 61
1 63
65 1
67 1
1 69
1 71
1 73
1 75
1 77
79 1
1 81
1 83
1 85
1 87
89 1
1 91
93 1
95 1
97 1
1 99
1 101
103 1
105 1
107 1
1 109
111 1
1 113
1 ...

output:

1
0
512
0
511
0
510
64
63
0
62
61
60
59
58
0
509
57
56
55
508
54
53
52
51
50
49
0
507
0
48
0
506
47
46
45
505
0
44
43
42
41
504
40
503
0
39
38
37
0
502
36
35
34
501
0
33
32
31
30
500
29
28
0
27
0
499
26
498
0
497
0
25
0
24
23
22
21
20
19
496
0
18
17
495
0
16
15
14
0
13
12
11
0
10
9
8
0
7
0
494
0
493...

result:

ok q=100000

Test #181:

score: 0
Accepted
time: 484ms
memory: 4996kb

input:

970 100000
2 1
3 1
5 1
1 7
9 1
11 1
1 13
15 1
1 17
19 1
21 1
23 1
1 25
1 27
29 1
1 31
1 33
1 35
1 37
39 1
41 1
1 43
45 1
1 47
1 49
51 1
53 1
1 55
1 57
59 1
1 61
63 1
1 65
67 1
69 1
71 1
73 1
75 1
1 77
1 79
1 81
83 1
1 85
87 1
89 1
1 91
1 93
95 1
1 97
1 99
1 101
103 1
105 1
107 1
1 109
111 1
113 1
11...

output:

0
64
63
62
61
60
59
58
57
56
55
54
53
52
0
0
0
0
1
512
0
0
51
0
50
0
511
49
48
47
510
0
46
45
44
509
0
43
42
41
40
39
508
507
506
0
0
0
38
0
37
36
0
0
35
0
0
0
0
0
505
34
33
0
0
0
504
0
0
0
0
503
502
501
500
499
498
497
496
0
0
32
0
495
31
494
493
0
0
492
491
490
489
488
0
30
29
28
27
26
0
0
25
0
48...

result:

ok q=100000

Test #182:

score: 0
Accepted
time: 107ms
memory: 4992kb

input:

970 100000
1 3
4 1
1 10
1 13
16 1
19 1
22 1
1 25
28 1
1 31
34 1
40 1
43 1
58 1
61 1
1 64
70 1
73 1
76 1
82 1
85 1
1 91
94 1
1 100
1 103
1 109
1 112
115 1
118 1
1 127
1 130
1 133
136 1
1 139
142 1
157 1
1 160
1 163
1 166
1 178
1 184
1 187
1 190
193 1
1 196
199 1
1 205
208 1
217 1
1 220
223 1
226 1
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 #183:

score: 0
Accepted
time: 108ms
memory: 4992kb

input:

970 100000
2 1
10 1
13 1
16 1
22 1
25 1
1 28
31 1
1 34
1 37
40 1
1 46
49 1
55 1
70 1
1 76
1 79
1 82
85 1
1 88
106 1
1 109
1 112
1 115
1 118
124 1
127 1
130 1
1 136
1 139
1 145
1 154
1 157
1 160
163 1
166 1
1 172
1 175
181 1
184 1
193 1
1 196
1 208
211 1
214 1
220 1
223 1
229 1
232 1
1 235
1 238
247 ...

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
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
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 #184:

score: 0
Accepted
time: 100ms
memory: 5080kb

input:

970 100000
3 1
4 1
1 7
10 1
13 1
16 1
19 1
1 22
1 25
1 28
37 1
1 40
43 1
46 1
1 49
52 1
1 55
1 58
1 64
1 67
1 70
73 1
76 1
79 1
1 85
91 1
94 1
97 1
106 1
1 109
1 112
115 1
1 118
1 124
127 1
133 1
139 1
1 142
1 148
1 154
157 1
160 1
1 163
166 1
169 1
172 1
175 1
181 1
1 184
187 1
1 190
1 193
199 1
1 ...

output:

1
0
256
0
255
0
210
64
448
0
63
62
61
60
254
59
253
252
58
251
447
0
57
56
55
54
53
52
51
50
49
48
47
0
46
0
45
44
43
0
42
41
40
39
446
0
250
0
249
0
248
38
37
36
35
34
247
33
246
32
31
0
245
244
30
29
28
243
445
27
26
25
24
0
23
22
21
242
241
0
20
19
18
17
444
0
443
240
239
0
238
237
236
235
16
234...

result:

ok q=100000

Test #185:

score: 0
Accepted
time: 488ms
memory: 5928kb

input:

970 100000
1 2
1 4
1 7
10 1
1 13
16 1
1 19
1 22
1 25
28 1
1 37
49 1
1 52
1 55
1 67
1 70
1 73
79 1
85 1
1 88
1 91
1 94
1 97
1 100
103 1
1 106
112 1
118 1
124 1
1 133
1 136
139 1
142 1
145 1
1 154
160 1
1 163
1 172
1 175
178 1
181 1
184 1
193 1
1 196
199 1
1 205
208 1
211 1
1 220
223 1
232 1
1 235
238...

output:

1
256
255
254
253
252
251
64
63
62
61
60
59
58
211
448
0
0
0
57
56
55
447
446
250
249
248
0
0
54
53
52
247
246
245
244
243
242
241
240
239
238
237
236
445
0
235
234
233
232
231
230
444
51
50
49
48
47
229
228
227
226
225
0
46
45
44
43
42
41
40
224
39
38
37
223
222
221
443
442
220
36
35
219
34
33
32
3...

result:

ok q=100000

Test #186:

score: 0
Accepted
time: 107ms
memory: 5012kb

input:

970 100000
3 1
5 1
1 9
13 1
17 1
21 1
29 1
1 33
1 37
1 41
1 49
53 1
57 1
69 1
1 73
1 77
1 81
85 1
1 89
93 1
97 1
1 101
1 105
1 117
121 1
125 1
1 129
133 1
137 1
141 1
1 145
1 149
153 1
157 1
1 161
169 1
1 173
1 181
185 1
189 1
193 1
1 197
201 1
209 1
213 1
217 1
1 221
225 1
229 1
1 233
241 1
1 245
2...

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 #187:

score: 0
Accepted
time: 101ms
memory: 4992kb

input:

970 100000
1 3
1 4
5 1
9 1
13 1
17 1
1 21
25 1
29 1
33 1
1 37
1 49
1 53
1 57
61 1
65 1
69 1
1 73
81 1
1 85
89 1
1 105
1 113
1 117
1 121
1 125
129 1
133 1
1 137
141 1
1 145
149 1
153 1
1 157
1 161
1 165
1 189
1 193
197 1
201 1
1 205
209 1
1 213
1 217
221 1
225 1
229 1
237 1
1 241
1 245
1 249
1 253
26...

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
210
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
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 #188:

score: 0
Accepted
time: 96ms
memory: 5004kb

input:

970 100000
2 1
1 3
4 1
1 5
1 9
1 13
17 1
1 21
1 25
33 1
1 37
41 1
1 45
49 1
57 1
61 1
1 65
69 1
1 73
81 1
1 85
1 89
1 97
1 101
105 1
1 113
1 117
1 121
125 1
1 129
133 1
137 1
1 141
149 1
153 1
1 157
1 161
1 165
169 1
1 173
1 177
1 181
185 1
189 1
197 1
1 201
205 1
1 209
1 213
217 1
1 221
1 229
233 1...

output:

64
0
3
0
63
62
61
60
59
2
448
0
447
446
640
1
639
58
57
56
55
0
638
54
53
256
52
51
255
50
254
49
253
252
251
250
445
444
249
443
48
442
248
247
47
46
45
44
43
42
441
246
440
41
40
39
38
37
36
0
35
34
245
0
244
243
242
439
637
241
240
239
238
438
437
33
32
31
30
29
28
27
26
25
24
237
436
23
22
21
23...

result:

ok q=100000

Test #189:

score: 0
Accepted
time: 480ms
memory: 4988kb

input:

970 100000
2 1
1 3
4 1
1 5
1 9
13 1
1 17
1 21
1 33
1 37
1 41
45 1
49 1
53 1
57 1
1 61
1 65
1 69
73 1
1 77
1 81
85 1
1 89
1 93
97 1
1 101
105 1
1 109
1 117
1 121
125 1
1 129
137 1
1 141
145 1
1 149
1 153
161 1
1 169
1 173
1 177
181 1
1 185
1 189
1 193
197 1
1 201
205 1
1 209
213 1
217 1
1 229
233 1
2...

output:

3
64
63
62
61
2
640
639
60
59
58
57
56
55
54
53
52
51
448
50
49
48
47
447
446
445
46
45
44
43
42
444
443
638
637
442
441
636
635
440
1
256
255
254
439
634
253
252
251
250
249
438
437
436
435
434
433
432
431
248
247
246
245
244
243
242
241
240
239
238
237
236
633
235
234
233
430
232
231
230
229
228
2...

result:

ok q=100000

Test #190:

score: 0
Accepted
time: 102ms
memory: 4920kb

input:

970 93610
1 3
1 4
1 6
1 11
16 1
21 1
1 26
1 31
36 1
1 41
46 1
1 51
56 1
1 61
1 66
1 71
76 1
81 1
86 1
1 91
96 1
101 1
106 1
1 111
1 116
121 1
126 1
1 131
136 1
141 1
1 146
1 151
1 156
161 1
1 166
171 1
176 1
181 1
186 1
1 191
1 196
1 201
1 206
211 1
216 1
1 221
1 226
1 231
236 1
241 1
246 1
1 251
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 #191:

score: 0
Accepted
time: 93ms
memory: 6060kb

input:

970 93610
5 1
6 1
1 11
16 1
1 21
26 1
1 31
36 1
41 1
46 1
1 51
56 1
1 61
1 66
1 71
1 76
81 1
86 1
1 91
96 1
1 101
106 1
1 111
1 116
121 1
1 126
1 131
1 136
1 141
146 1
1 151
1 156
161 1
1 166
1 171
176 1
1 181
1 186
1 191
196 1
1 201
1 206
1 211
1 216
1 221
226 1
1 231
236 1
1 241
1 246
1 251
1 256
...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
196
584
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
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 #192:

score: 0
Accepted
time: 110ms
memory: 5044kb

input:

970 93610
1 2
1 3
4 1
1 5
6 1
1 11
16 1
21 1
1 26
1 31
1 36
41 1
46 1
1 51
1 56
61 1
1 66
1 71
76 1
1 81
86 1
1 91
1 96
1 101
106 1
111 1
116 1
121 1
1 126
1 131
1 136
141 1
146 1
1 151
156 1
1 161
1 166
171 1
1 176
1 181
186 1
1 191
196 1
201 1
1 206
1 211
1 216
1 221
1 226
231 1
1 236
1 241
246 1
...

output:

2
64
448
63
62
61
60
4
3
1
59
256
255
254
58
253
57
56
55
252
54
53
52
51
50
49
48
47
46
198
447
45
44
43
42
41
40
39
38
251
250
37
36
35
34
33
32
31
30
29
28
27
26
249
248
25
24
247
246
640
832
0
245
244
243
0
23
22
831
242
241
240
239
446
445
444
238
21
237
20
19
18
236
235
234
233
232
17
16
15
14...

result:

ok q=100000

Test #193:

score: 0
Accepted
time: 457ms
memory: 5140kb

input:

970 93610
1 3
1 6
1 11
1 16
21 1
26 1
1 31
36 1
41 1
46 1
51 1
1 56
61 1
66 1
1 71
1 76
81 1
1 86
91 1
96 1
1 101
106 1
1 111
116 1
1 121
1 126
1 131
1 136
141 1
146 1
151 1
156 1
1 161
166 1
1 171
1 176
1 181
1 186
1 191
1 196
201 1
1 206
1 211
216 1
221 1
226 1
231 1
1 236
1 241
1 246
1 251
1 256
...

output:

256
64
63
62
61
60
59
58
1
255
254
253
252
251
0
0
0
0
195
448
447
446
445
444
443
250
442
390
640
0
0
57
56
55
54
53
52
51
50
49
48
47
46
45
44
43
249
196
391
832
831
830
42
41
40
39
248
441
440
439
438
247
246
245
244
243
242
241
38
37
36
35
34
33
32
31
240
239
30
29
28
27
26
25
24
23
238
237
236
...

result:

ok q=100000

Test #194:

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

input:

970 77288
1 2
3 1
1 4
5 1
1 7
13 1
1 19
1 25
31 1
37 1
43 1
1 49
1 55
61 1
1 67
1 73
1 79
1 85
91 1
97 1
103 1
1 109
115 1
121 1
1 127
133 1
139 1
1 145
1 151
1 157
1 163
169 1
175 1
181 1
187 1
193 1
199 1
205 1
1 211
217 1
1 223
1 229
1 235
241 1
1 247
253 1
259 1
1 265
271 1
1 277
1 283
289 1
1 2...

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
3
165
487
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
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 #195:

score: 0
Accepted
time: 80ms
memory: 5824kb

input:

970 77288
1 2
5 1
1 6
7 1
13 1
19 1
1 25
31 1
37 1
43 1
49 1
55 1
61 1
1 67
1 73
1 79
1 85
91 1
1 97
103 1
109 1
115 1
1 121
127 1
1 133
139 1
145 1
151 1
157 1
1 163
1 169
175 1
1 181
1 187
1 193
199 1
1 205
1 211
1 217
223 1
1 229
235 1
1 241
1 247
253 1
1 259
1 265
1 271
1 283
289 1
295 1
301 1
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
164
327
326
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2
487
0
0
0
0
0
0
1
165
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok q=100000

Test #196:

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

input:

970 77288
2 1
1 5
1 6
1 7
1 13
1 19
1 25
1 31
37 1
43 1
1 49
1 55
61 1
67 1
73 1
79 1
1 85
91 1
97 1
103 1
109 1
1 115
1 121
127 1
133 1
139 1
145 1
1 151
157 1
1 163
169 1
175 1
1 181
187 1
1 193
199 1
1 205
1 211
1 217
223 1
229 1
235 1
1 241
247 1
253 1
1 259
265 1
271 1
277 1
1 283
1 289
295 1
3...

output:

164
1
384
2
165
192
191
190
189
188
704
383
703
0
327
3
64
166
382
512
487
187
186
702
381
63
62
61
185
184
380
379
832
60
59
58
183
182
181
378
57
56
180
179
178
177
176
175
174
55
173
701
54
53
52
51
50
49
48
700
831
699
47
698
511
172
171
170
510
46
45
44
43
42
41
40
39
38
37
36
35
34
33
32
31
30...

result:

ok q=100000

Test #197:

score: 0
Accepted
time: 381ms
memory: 4796kb

input:

970 77288
2 1
1 4
1 5
1 7
13 1
1 25
31 1
37 1
43 1
1 49
1 55
61 1
67 1
73 1
1 79
1 85
1 91
97 1
1 103
1 109
1 115
121 1
127 1
1 133
1 139
1 145
1 151
1 157
163 1
169 1
175 1
1 181
1 187
193 1
199 1
1 205
211 1
1 217
223 1
229 1
235 1
1 241
1 247
1 253
1 259
1 265
1 271
1 277
283 1
1 289
295 1
301 1
...

output:

64
63
62
61
1
192
191
190
60
59
58
57
56
55
54
53
52
51
50
49
48
161
320
3
384
482
704
0
0
2
512
511
510
509
508
189
188
47
46
45
44
43
187
186
185
184
183
182
181
383
382
381
42
41
40
39
38
37
36
35
34
33
32
31
30
29
28
27
26
25
24
23
22
21
20
19
18
180
179
17
16
15
14
13
12
178
177
176
175
380
379...

result:

ok q=100000

Test #198:

score: 0
Accepted
time: 86ms
memory: 4820kb

input:

970 66182
2 1
1 3
4 1
1 6
7 1
1 8
15 1
1 22
1 29
36 1
43 1
50 1
1 57
1 64
1 71
1 85
1 92
99 1
1 106
113 1
1 120
1 127
1 134
1 141
148 1
155 1
162 1
1 169
1 176
1 183
190 1
1 197
204 1
1 218
225 1
232 1
239 1
246 1
1 253
1 260
1 267
1 274
281 1
1 288
1 295
302 1
1 309
316 1
323 1
1 330
337 1
1 344
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
140
557
0
0
0
0
0
4
141
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
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 #199:

score: 0
Accepted
time: 70ms
memory: 4732kb

input:

970 66182
1 4
5 1
1 6
7 1
8 1
15 1
1 22
29 1
36 1
43 1
1 50
1 57
1 64
71 1
1 78
1 85
92 1
1 99
1 106
1 113
1 120
127 1
134 1
1 141
1 148
1 155
162 1
1 169
1 176
183 1
1 190
197 1
1 204
211 1
1 218
1 225
232 1
239 1
246 1
253 1
260 1
267 1
274 1
281 1
288 1
295 1
1 302
309 1
1 316
1 323
330 1
337 1
3...

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
2
144
56...

result:

ok q=100000

Test #200:

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

input:

970 66182
1 2
1 5
1 7
8 1
1 15
22 1
1 29
1 36
43 1
1 57
64 1
1 71
1 78
85 1
1 92
1 99
106 1
1 113
1 120
1 127
134 1
141 1
148 1
155 1
1 162
1 169
1 176
1 183
1 190
197 1
204 1
211 1
1 218
225 1
232 1
1 239
1 246
253 1
260 1
267 1
274 1
281 1
1 288
295 1
1 302
1 309
316 1
1 323
1 330
1 337
344 1
351 ...

output:

320
3
141
319
2
318
64
63
62
61
60
59
140
279
278
1
448
317
192
316
315
280
191
447
314
446
445
444
58
57
56
55
54
53
52
51
50
49
48
47
46
45
44
43
42
41
40
39
38
37
558
36
896
190
35
34
33
32
31
30
313
419
895
418
443
442
441
29
28
440
312
311
310
309
308
307
439
27
26
306
305
304
438
437
25
436
18...

result:

ok q=100000

Test #201:

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

input:

970 66182
4 1
1 5
6 1
1 8
15 1
1 22
1 29
1 36
43 1
1 50
1 57
1 64
1 71
78 1
85 1
92 1
1 99
106 1
1 113
120 1
1 127
134 1
1 141
148 1
155 1
162 1
169 1
1 176
183 1
1 190
197 1
204 1
1 211
1 218
225 1
232 1
1 239
1 246
1 253
1 260
267 1
274 1
1 281
288 1
295 1
302 1
309 1
316 1
323 1
330 1
337 1
344 1...

output:

0
142
2
64
63
62
61
60
59
58
57
56
55
54
53
52
51
50
49
48
47
46
45
44
43
3
42
41
40
39
38
37
36
35
1
192
191
190
189
34
33
32
31
30
29
28
27
26
188
187
186
185
184
183
182
181
25
180
179
178
177
176
175
174
173
172
171
170
169
24
23
22
21
168
167
144
143
282
418
281
448
447
417
557
704
446
445
444
...

result:

ok q=100000

Test #202:

score: 0
Accepted
time: 66ms
memory: 6048kb

input:

970 58094
3 1
1 4
1 5
1 7
8 1
1 9
17 1
1 25
33 1
1 41
49 1
1 57
1 65
73 1
81 1
1 89
97 1
105 1
113 1
1 121
1 129
137 1
145 1
153 1
161 1
169 1
1 177
1 185
193 1
1 201
1 209
1 217
1 225
233 1
1 241
249 1
1 257
265 1
273 1
1 281
1 289
297 1
1 305
1 313
321 1
329 1
1 337
1 345
1 353
1 361
369 1
1 377
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
248
610
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
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 #203:

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

input:

970 58094
3 1
5 1
1 9
17 1
25 1
33 1
1 41
49 1
57 1
1 65
1 73
1 81
1 89
1 97
105 1
1 113
121 1
1 129
137 1
1 145
1 153
1 161
1 169
1 177
1 185
193 1
1 201
209 1
217 1
225 1
233 1
1 241
1 249
1 257
1 265
1 273
1 281
289 1
297 1
305 1
313 1
1 321
329 1
1 337
1 345
353 1
1 361
1 369
1 377
1 385
1 393
4...

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
2
1
0
0
0
0
0
125
249
371
493
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
124
248
494
0
0
0
0
0
0
0
...

result:

ok q=100000

Test #204:

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

input:

970 58094
2 1
5 1
1 6
7 1
1 8
1 9
17 1
25 1
1 33
41 1
1 49
1 57
1 65
1 73
1 81
89 1
97 1
1 105
113 1
1 121
1 129
137 1
1 145
1 153
1 161
1 169
1 177
1 185
193 1
1 201
209 1
217 1
1 225
233 1
241 1
1 249
257 1
265 1
273 1
1 281
1 289
297 1
305 1
1 313
321 1
329 1
337 1
345 1
1 353
1 361
369 1
377 1
1...

output:

64
63
62
3
128
127
2
4
129
1
192
5
191
190
256
255
254
253
250
371
249
384
61
60
59
58
57
56
55
189
188
187
186
54
53
52
185
184
51
50
49
183
48
47
46
45
44
182
181
180
252
179
43
42
41
178
177
176
175
174
173
172
320
251
370
40
39
38
37
36
35
34
33
171
170
32
31
30
29
28
27
26
25
24
23
22
21
20
19
...

result:

ok q=100000

Test #205:

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

input:

970 58094
4 1
5 1
7 1
8 1
9 1
1 17
1 25
33 1
41 1
1 49
1 57
1 65
1 73
81 1
89 1
1 97
1 105
113 1
121 1
129 1
1 137
1 145
153 1
1 161
1 169
1 177
1 185
1 193
201 1
209 1
217 1
225 1
233 1
241 1
249 1
257 1
265 1
1 273
1 281
1 289
297 1
1 305
313 1
1 321
1 329
1 337
1 345
1 353
1 361
1 369
377 1
385 1...

output:

0
128
0
4
130
254
375
2
512
511
1
127
252
384
383
382
381
510
126
256
255
253
320
319
318
317
316
315
314
3
129
313
312
768
767
766
765
764
763
495
762
761
760
64
63
62
61
60
59
58
57
56
55
54
53
52
51
50
49
48
47
46
45
44
43
42
41
40
39
38
192
37
36
35
34
33
32
31
30
29
28
27
26
25
24
23
311
310
30...

result:

ok q=100000

Extra Test:

score: 0
Extra Test Passed