QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#789234#3040. Containerthomas0702AC ✓1ms5776kbC++141.6kb2024-11-27 19:37:292024-11-27 19:37:31

Judging History

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

  • [2024-11-27 19:37:31]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:5776kb
  • [2024-11-27 19:37:29]
  • 提交

answer

#include<bits/stdc++.h>
#define pb push_back
using namespace std;
typedef pair<int,int> pii;
const int maxn=505;
int N,C,ps[maxn],pt[2][maxn],sum[2][maxn],f[maxn][maxn],fr[maxn][maxn],pos[maxn],d[maxn];
char s[maxn],t[maxn];
vector<int> E[maxn];
int main(){
	scanf("%d%d%s%s",&N,&C,s+1,t+1);
	for(int i=1;i<=N;i++){
		sum[0][i]=sum[0][i-1],sum[1][i]=sum[1][i-1];
		if(s[i]=='2') ps[++ps[0]]=i;
		if(t[i]=='2') pt[i&1][++pt[i&1][0]]=i,sum[i&1][i]++;
	}
	memset(f,0x3f,sizeof f);
	f[0][0]=0;
	for(int i=0;i<ps[0];i++){
		for(int j=0;j<=i;j++){
			if(j<pt[0][0]){
				int p=pt[0][j+1],d=abs(p-ps[i+1]),
				tmp=f[i][j]+(d+1)/2*C+d/2*4+(d&1)*3+max(0,sum[1][p]-(i-j));
				if(tmp<f[i+1][j+1]) f[i+1][j+1]=tmp,fr[i+1][j+1]=0;
			}
			if(i-j<pt[1][0]){
				int p=pt[1][i-j+1],d=abs(p-ps[i+1]),
				tmp=f[i][j]+(d+1)/2*C+d/2*4+(d&1)*3+max(0,sum[0][p]-j);
				if(tmp<f[i+1][j]) f[i+1][j]=tmp,fr[i+1][j]=1;
			}
		}
	}
	for(int i=ps[0],j=pt[0][0];i;)
		if(fr[i][j]) pos[i]=pt[1][i-j],i--;
		else pos[i]=pt[0][j],i--,j--;
	for(int i=1;i<=ps[0];i++)
		for(int j=i+1;j<=ps[0];j++)
			if(pos[i]<ps[i]&&pos[j]<ps[j]) d[j]++,E[i].pb(j);
			else if(pos[i]>ps[i]&&pos[j]>ps[j]) d[i]++,E[j].pb(i);
	queue<int> q;vector<pii> ans;
	for(int i=1;i<=ps[0];i++) if(!d[i]) q.push(i);
	while(!q.empty()){
		int u=q.front(),x=ps[u],y=pos[u];q.pop();
		while(x<=y-2) ans.pb({x,x+2}),x+=2;
		while(x>=y+2) ans.pb({x-2,x}),x-=2;
		if(x<y) ans.pb({x,y});
		if(x>y) ans.pb({y,x});
		for(int v:E[u]) if(!--d[v]) q.push(v);
	}
	printf("%d\n",(int)ans.size());
	for(pii i:ans) printf("%d %d\n",i.first,i.second);
	return 0;
}

详细

Test #1:

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

input:

5 2
11221
21112

output:

2
1 3
4 5

result:

ok good job!

Test #2:

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

input:

7 0
2212121
1212122

output:

4
6 7
4 6
2 4
1 2

result:

ok good job!

Test #3:

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

input:

7 2
2212121
1212122

output:

3
1 3
3 5
5 7

result:

ok good job!

Test #4:

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

input:

1 0
1
1

output:

0

result:

ok good job!

Test #5:

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

input:

1 100
2
2

output:

0

result:

ok good job!

Test #6:

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

input:

2 55
12
21

output:

1
1 2

result:

ok good job!

Test #7:

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

input:

3 100
112
211

output:

1
1 3

result:

ok good job!

Test #8:

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

input:

3 99
221
212

output:

1
2 3

result:

ok good job!

Test #9:

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

input:

3 98
111
111

output:

0

result:

ok good job!

Test #10:

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

input:

123 64
222111221111221122211121221221122122211222211112221221212121211221122212111212211222122212122221212121222121221112111112112
211112121222212221122212212122111121121212211211211212212211111221222212121121212222112212222211221211122212111211221122212

output:

110
12 14
114 116
15 17
110 112
16 18
109 111
111 113
113 115
115 117
117 119
119 121
17 19
107 109
109 111
111 113
113 115
115 117
117 119
21 23
105 107
107 109
109 111
111 113
113 115
24 26
22 24
20 22
104 106
106 108
26 28
24 26
22 24
103 105
105 106
27 29
101 103
103 105
30 32
28 30
26 28
24 26
...

result:

ok good job!

Test #11:

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

input:

337 42
12221211121211122121211211221211122221122211222222112211121111121211112112222111112212222222211111212211212211221111112121121211112121211222222211122211121211121121121212111112212211122122121112212122212121112111222222112112221222122112221121212212221222212211112211222211112212121221221222111...

output:

683
9 10
336 337
10 12
331 333
333 334
14 16
12 14
330 332
15 17
13 15
329 330
17 19
323 324
19 21
320 322
22 24
20 22
18 20
16 18
14 16
318 320
25 27
23 25
21 23
112 114
114 115
26 28
24 26
22 24
102 103
28 30
93 95
32 34
30 32
91 93
33 35
31 33
29 31
27 29
58 59
34 36
54 56
56 57
35 37
53 55
38 40...

result:

ok good job!

Test #12:

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

input:

312 225
1211111122221112212122121121211212111222121212112121211221211122121111121212211221122221212122111111121222121222112121122222222111111211212112222111222221122211222221122112212112121122222121212111121211212222211122212122111221212222122222122211222211221211111221112111121122222122122111211212...

output:

254
7 9
5 7
305 307
8 10
6 8
4 6
304 305
9 11
7 9
293 295
295 297
297 298
10 12
8 10
292 294
294 296
14 16
12 14
10 12
9 10
265 266
15 17
13 15
254 256
17 19
15 17
252 254
19 21
209 210
20 22
18 20
16 18
198 199
22 24
20 22
18 20
193 195
195 196
25 27
23 25
191 193
193 195
27 29
189 191
30 32
29 30
...

result:

ok good job!

Test #13:

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

input:

5 136
22111
21121

output:

1
2 4

result:

ok good job!

Test #14:

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

input:

401 518
2122122212112221121122221122212212111122222112211121112212211221211211111111111121222112122212122122112112222211212221212211221222212222211212211222221122212221121211112111221112211122121212112222122112122221112111112222121111122111221211212111211222112222112112211112122212111112211221111122...

output:

1263
82 84
398 399
87 88
396 398
88 90
393 395
386 388
388 390
390 392
392 394
384 386
386 388
388 390
390 392
383 385
385 387
387 389
389 391
391 393
381 383
383 385
385 387
387 389
378 380
380 382
382 384
384 386
386 388
375 377
377 379
379 381
381 383
383 385
372 374
374 376
376 378
378 380
380 3...

result:

ok good job!

Test #15:

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

input:

309 504
1122112211111111121121111122122122211211112122111211211212121221121122111212121112222121122211122111222122212112111112111221222111221212111111112112121211211222212212222122212112222222222211122111121112112122111211121222222211221121222111111211222121111221211111112111122111212111221212212211...

output:

769
16 18
14 16
12 14
10 12
257 259
19 21
17 19
15 17
13 15
249 251
251 252
25 27
23 25
21 23
19 21
17 19
16 17
247 249
26 28
24 26
22 24
20 22
246 248
28 30
26 28
24 26
22 24
245 247
29 31
27 29
25 27
23 25
21 23
242 244
31 33
235 237
237 239
239 241
32 34
30 32
28 30
26 28
24 26
234 236
236 238
23...

result:

ok good job!

Test #16:

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

input:

442 357
1121121122111122112211222222211112121111122111121122121121112212222222121121111111212122122121222222212122211111211112222221112112122222211122212122222221222211221212211122121221111222112222212122122212212221111121122212221122221111212112211212211222112211122212112211122222112222221221111112...

output:

782
2 3
438 440
13 15
434 436
14 16
12 14
431 433
433 435
435 437
437 439
439 441
17 19
15 17
428 430
430 432
432 434
18 20
16 18
14 16
426 428
428 430
21 23
19 21
398 400
22 24
20 22
18 20
16 18
394 396
396 398
23 25
21 23
392 393
24 26
22 24
358 360
360 362
362 364
25 27
356 358
358 360
360 361
26...

result:

ok good job!

Test #17:

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

input:

499 399
2122122112111122122122111112211112121112121112222111211122112222221221221111212221222211111221221211212211212222112221221212212211121212122122211212212222122122111212111212221121222112111122122111112122211212122221222222211221112212221122122112121212211121121222221121112112111112222211211122...

output:

1316
2 3
488 490
490 491
13 15
487 489
14 16
484 486
16 18
483 485
485 487
17 19
15 17
479 481
481 483
483 484
19 21
478 480
20 22
477 479
26 28
24 26
22 24
21 22
430 432
432 434
27 29
25 27
23 25
428 430
430 432
32 34
30 32
28 30
26 28
425 427
427 429
34 36
32 34
30 32
29 30
422 424
424 426
426 428...

result:

ok good job!

Test #18:

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

input:

36 857
212211211121121112122222121222222222
221221122222212222121112211112221221

output:

56
2 3
5 7
9 11
12 14
10 12
8 10
16 18
14 16
12 14
10 12
18 20
16 18
14 16
12 14
11 12
19 21
17 19
15 17
13 15
20 22
18 20
16 18
14 16
12 14
21 23
19 21
17 19
15 17
22 24
20 22
18 20
16 18
24 26
22 24
20 22
18 20
26 28
24 26
22 24
20 22
27 29
25 27
23 25
21 23
19 21
17 19
28 30
26 28
24 26
29 31
27 ...

result:

ok good job!

Test #19:

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

input:

371 54
11122122211122221221111111111112122222112111211111121111111221121212211122121211211112111111121121112122222211121222222211211222211222221222221122211221211211221112222112221121111222122211211211212121112121212111221222221111122222112121112212111121211112222211222222222122212221221221212121212...

output:

1462
2 4
333 335
3 5
1 3
330 332
332 333
6 7
326 328
328 330
11 13
325 327
327 329
30 32
28 30
26 28
324 326
32 34
322 324
33 35
321 323
323 325
34 36
318 320
320 322
322 323
35 37
316 318
318 320
320 322
36 38
315 317
317 319
319 321
39 41
37 39
314 316
316 318
318 319
43 45
41 43
39 41
313 315
315...

result:

ok good job!

Test #20:

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

input:

209 349
22122112221111121222122221222211222112221112121122122112221222121121212211211111111212111122222211121221221121211111221212111111112221222222212211222222212212221111212112221222211122212121112122222222211222122
1222112122222212222221222212211212221222121222112122211121111211122222212111221122...

output:

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

result:

ok good job!

Test #21:

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

input:

157 626
1221122121222222211112121122211122212112122222221211221111212112222221221111121212222212112221222121221111222122121112111121111211121221112212221112212122212
22122221221221211212212212111122112122121211212211222112122211121222222212122212121121221211211221212121122211122111112221221111212121...

output:

91
1 3
143 145
4 6
118 120
120 121
5 7
114 116
116 118
118 120
7 9
111 113
113 115
115 117
117 119
9 11
109 111
111 113
10 12
8 10
6 8
102 104
104 106
12 14
10 12
101 103
14 16
12 14
99 101
20 22
97 99
25 27
23 25
21 23
95 97
26 28
69 70
27 29
25 27
23 25
67 69
31 33
65 67
32 34
54 56
56 58
38 40
50...

result:

ok good job!

Test #22:

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

input:

447 512
1211212211222111221122222111212112111212111121221111122121122111111112121222222211222212111211122121111222221112111211112211121221122122121222221212211222112122221211121211222212112221121221211111111221222111211121121122112211122211212112211121121222121111212112112111111122222122121111211111...

output:

814
1 2
413 415
3 5
405 407
407 409
409 411
411 413
413 414
5 7
404 406
406 408
408 410
410 412
44 45
403 405
405 407
407 409
409 411
411 413
52 54
402 404
404 406
406 408
408 410
68 70
66 68
401 403
403 405
405 407
407 409
409 411
70 72
68 70
393 395
395 397
397 399
399 401
401 403
403 405
405 407
...

result:

ok good job!

Test #23:

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

input:

304 553
2222111221212211222222221121121212121212111121212111212212211121121111121222221222211112111111211122212111112111221121211222221222112211212121222212112221111111212121122221222222211121121121221122121212212211212212122121122121121122111211212211221222221211221221211112212222212111111211211111...

output:

609
94 95
300 302
302 304
97 99
296 298
298 300
300 302
98 100
96 98
287 289
289 291
291 293
293 295
295 297
297 299
299 301
301 303
99 101
98 99
284 286
286 288
288 290
290 292
292 294
294 296
296 298
298 300
101 103
100 101
277 279
279 281
281 283
283 285
285 287
287 289
289 291
291 293
293 295
29...

result:

ok good job!

Test #24:

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

input:

300 283
1222222212221212221112211121121112112111122122211121112212221222121112211111111112221121111211112122112222211122222221121221112211212112121122122122212221221212122111211221222211122212222122212111122121111221221222122122222111122121111111211222122221221211211111122221212112221211212222211211...

output:

803
1 2
297 299
2 4
23 25
28 30
22 24
24 26
32 34
30 32
18 20
20 22
22 23
35 37
33 35
31 33
29 31
17 19
19 21
40 42
38 40
36 38
34 36
16 18
18 19
41 43
39 41
37 39
35 37
33 35
14 16
16 18
43 45
41 43
39 41
37 39
12 14
44 46
42 44
40 42
38 40
11 13
13 15
15 17
45 47
43 45
41 43
10 12
49 51
47 49
45 4...

result:

ok good job!

Test #25:

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

input:

387 146
2211222121111211111222212111121112121122122212112212122212111222212111121211222222111121221221221121112221111122112122211212211222122211122221122211112111211211222211112212222122211122121222212221112122112211122112211112122211122222111221221121122212211221211111211211212211221122212112212212...

output:

450
110 112
108 110
309 311
113 115
305 307
307 309
116 118
114 116
112 114
301 303
303 305
305 307
120 122
118 120
116 118
114 116
300 302
302 304
304 306
306 308
308 310
122 124
120 122
118 120
116 118
299 301
301 303
303 305
160 162
296 298
298 300
300 302
302 304
304 306
162 163
295 297
297 299
...

result:

ok good job!

Test #26:

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

input:

66 369
112112222112111112212111221111122112211221221212111112221112221212
222211122211221212221121111111111212121211122111221221212212121111

output:

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

result:

ok good job!

Test #27:

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

input:

79 896
1212112112112222111112121112111222211112122112221212221111121111111222121211221
1211212212212221111111221121122111111121121121221212111212222211212212111111221

output:

55
8 10
60 61
11 13
54 56
56 58
58 60
12 14
10 12
53 55
55 57
57 59
13 15
52 54
54 56
56 58
14 16
50 52
52 54
54 56
20 22
18 20
16 18
15 16
48 50
50 52
23 24
46 48
48 50
26 28
24 26
43 45
30 32
28 30
27 28
42 44
44 46
46 48
31 33
40 42
32 34
30 32
35 37
37 39
66 68
64 66
62 64
4 5
67 69
65 67
68 70
...

result:

ok good job!

Test #28:

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

input:

231 339
112211112111122222122122111122221111222221221111111121222122112211111221121122121121211221121212221221122111221221212222211221122221122222121111122211121121112111212112211211221211111221211222212122212112122112111211212112111122112
111112211221211112112221211122111222222211222122122112111221...

output:

244
12 14
11 12
228 230
13 15
227 229
51 53
49 51
48 49
222 224
224 226
53 55
51 53
219 221
221 223
223 225
225 227
54 56
52 54
50 52
217 219
219 221
221 223
55 57
54 55
214 216
216 218
218 220
58 60
210 212
212 214
214 216
216 218
61 63
207 209
209 211
211 213
213 215
215 217
217 219
219 221
62 64
...

result:

ok good job!

Test #29:

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

input:

109 984
2121221222211211121212122121112211121221221122222122111111112121212122112212111222111111221122111121211122112
1111212122211121112222112221112112121111211211111222112112222112121112222112112111221122121122211222112122212

output:

209
105 107
101 103
103 105
99 101
101 103
94 96
96 98
98 100
93 95
95 97
97 99
90 92
92 94
94 96
96 98
89 91
91 93
93 95
82 84
84 86
86 88
88 90
90 92
92 94
81 83
83 85
85 87
87 89
89 91
91 93
80 82
82 84
84 86
86 88
88 90
76 78
78 80
80 82
82 84
84 86
86 88
74 76
76 78
78 80
80 82
82 84
73 75
75 7...

result:

ok good job!

Test #30:

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

input:

33 61
221112222112212211212221112222221
222112222211222112122121112122221

output:

16
5 7
3 5
7 9
10 12
11 13
9 11
13 15
14 16
17 19
15 17
20 22
18 20
26 28
24 26
22 24
20 22

result:

ok good job!

Test #31:

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

input:

402 243
2211121211221211111221122111221221221112121221211211111221221222211212121111122121111211222222211112112122212211122211122121122212211122222221221121112212122221112222111221122212221111211121222112211122211212111111122221122211122122211122121212122212122112211122111211221222112111112121112212...

output:

570
4 6
393 395
395 397
397 399
399 401
6 8
5 6
391 393
393 395
10 12
8 10
6 8
387 389
389 391
391 393
18 20
16 18
383 385
19 21
17 19
382 384
384 386
386 388
22 24
381 383
23 25
21 23
380 382
382 384
384 386
27 29
25 27
23 25
378 380
380 382
382 384
28 30
26 28
377 379
379 381
30 32
28 30
376 378
3...

result:

ok good job!

Test #32:

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

input:

380 225
1122122211112212212122121222211212122222212121112212111221222111121221122112212222212212121122112221122211221211222212211211211212221111211112212112212222111122112211121222222112211122122111112112221211221211112111222221222112112111212121222122212111222122212211112122212111112212112211122222...

output:

774
1 3
187 189
189 191
2 4
186 188
188 190
4 6
184 186
6 8
183 185
185 187
187 189
11 13
9 11
179 181
181 183
183 185
12 14
178 180
180 182
182 184
15 17
13 15
11 13
175 177
177 179
179 181
181 183
17 19
15 17
13 15
174 176
176 178
178 180
194 196
192 194
173 175
175 177
177 179
179 181
195 197
172...

result:

ok good job!

Test #33:

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

input:

310 958
2222122112221211222222112111112211211221122212211121212221221221212122112221121121222222122121212222121222211211211122212112112122121222222111222212112211212121222112212121121212112212212212121112211111212221222212221112221212212221211122222121221112221222222211121122211212212112212111112122...

output:

690
29 31
305 307
307 309
30 32
28 30
304 306
306 308
308 310
33 35
31 33
303 305
305 307
36 38
34 36
300 302
302 304
304 306
38 39
298 300
300 302
302 304
40 42
297 299
299 301
301 303
303 305
41 43
296 298
298 300
300 302
42 44
295 297
297 299
299 301
301 303
44 46
43 44
294 296
296 298
298 300
45...

result:

ok good job!

Test #34:

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

input:

424 565
2121222121112111112211111112121221212221122222221211212112112121122122211222112111222211111122122112111221222211212221211121122212112121112212112121212121121112211111122211122222122212111111112221122122112212222222121112222222211112211212121212221222212121112212212112222111122212211221122111...

output:

1137
2 3
13 14
17 19
15 17
9 11
18 20
16 18
7 9
9 10
26 28
24 26
22 24
20 22
18 20
6 8
28 30
26 28
24 26
22 24
20 22
30 32
28 30
26 28
24 26
22 24
31 33
29 31
27 29
25 27
23 25
21 23
19 21
17 19
33 35
31 33
29 31
27 29
25 27
23 25
21 23
35 37
33 35
31 33
29 31
27 29
25 27
23 25
36 38
34 36
32 34
30 ...

result:

ok good job!

Test #35:

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

input:

348 808
1212221222122212121111111122121211221212111111222122112211121211211112222212211111221222221211211212111221111222122111121122112111221111211112222212111221221121221211111221111122121121211212121211222121111212122112222111222122111212221211111212121222121111122112112211221121111112111221211122...

output:

300
54 56
346 348
58 60
57 58
344 345
60 62
58 60
342 343
68 70
66 68
64 66
337 339
339 341
69 71
335 337
70 72
68 70
66 68
334 335
140 142
326 328
176 177
325 327
195 197
193 195
191 193
189 191
187 189
252 254
200 201
249 251
204 206
242 243
209 211
207 209
205 207
203 205
236 238
238 240
240 241
...

result:

ok good job!

Test #36:

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

input:

72 980
212222212121221212221211122121121122212211112212121222121122121121122212
112212121112211212222112122222122112121122211112221112122212112212122222

output:

75
69 71
65 67
67 69
62 64
64 66
60 62
62 64
59 61
61 63
56 58
58 60
54 56
56 58
53 55
55 57
52 54
54 56
50 52
52 54
48 50
46 48
45 47
47 49
40 42
39 41
41 43
37 39
39 41
36 38
35 36
29 31
31 33
27 29
26 28
28 30
22 24
24 26
26 28
20 22
22 24
24 26
19 21
21 23
23 25
25 27
18 20
20 22
22 24
16 18
18 ...

result:

ok good job!

Test #37:

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

input:

51 563
112111212112122112222111111222121121111121212222112
112111122121211121111212221211121222112212112211212

output:

27
11 12
48 49
13 14
32 34
34 36
39 41
30 32
32 34
41 43
40 41
29 31
31 32
44 46
42 44
21 23
23 25
25 26
46 47
20 22
22 24
19 21
21 23
23 25
18 20
20 22
15 17
7 8

result:

ok good job!

Test #38:

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

input:

194 823
11211122111222111211221111212111222111111212221221221111122221221121111111111111111222112221221122221222211121212122221222212221211121121112122222122222111212112112122212122221221121111211222211
2212211222112211211212122211222212221211121221122111111111111222212122111112221211112111122112212...

output:

383
1 3
192 194
5 7
191 193
6 8
4 6
2 4
190 191
10 12
8 10
6 8
4 6
186 188
11 13
9 11
181 183
183 184
12 14
10 12
8 10
178 180
180 182
16 18
14 16
12 14
10 12
177 179
179 180
19 21
17 19
15 17
13 15
174 176
176 178
20 22
18 20
16 18
14 16
172 174
174 176
25 27
23 25
21 23
19 21
17 19
170 172
172 174...

result:

ok good job!

Test #39:

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

input:

218 200
21211222212221121221212121121121211111212222222212212211221111111111221121221211211111122211112222121122222122222121212111221111221122121112221122211121222122112112122222121221211222222211221112212121122211211121121222
2122111222221111211122221121122212221112211221112122211121212221121222221...

output:

351
4 6
211 213
37 39
35 37
207 209
39 41
37 39
36 37
204 206
206 208
208 210
210 212
40 42
203 205
41 43
197 198
67 69
66 67
58 60
60 62
68 70
57 59
59 61
61 63
71 73
69 71
54 56
56 58
58 60
60 61
73 75
71 73
53 55
55 57
57 59
74 76
72 74
70 72
51 53
53 55
55 57
76 78
74 76
72 74
50 52
52 53
79 81
...

result:

ok good job!

Test #40:

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

input:

261 918
121221112112122122111121212112212211111121111212111212221112121112121122121112221111222121111222121221222112111212211212212211212122122112122111112222212222212111122111222222211222112122222112122122121121111121222221121112121222212111211122111211111112122212222
111212211121211222212211211212...

output:

645
21 23
244 246
23 25
22 23
239 241
241 243
25 27
235 237
237 239
239 241
28 30
231 233
233 235
235 237
237 239
30 31
229 231
231 233
233 235
235 237
32 34
228 230
230 232
232 234
234 236
236 238
39 41
37 39
35 37
227 229
229 231
44 46
42 44
40 42
38 40
36 38
34 36
226 228
228 230
230 232
46 48
44...

result:

ok good job!

Test #41:

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

input:

412 618
1112222122111122221121221122222221121112222212121111111221221222111121122111111122122222112112122121111221121221111221111222121221221121111122111111212122111211221111211211211212211111112222121211222112212121222112121221222122121222211221222112112211222112222121111221212211221122211212222121...

output:

1314
2 4
405 407
407 409
4 5
402 404
404 406
8 10
401 403
403 405
405 407
13 15
11 13
398 400
400 402
402 404
14 16
12 14
396 398
15 17
14 15
395 397
20 21
389 391
25 27
387 389
389 390
58 60
385 387
387 388
60 62
383 385
385 386
67 69
381 383
70 72
68 70
380 382
382 384
71 73
69 71
378 380
79 81
77...

result:

ok good job!

Test #42:

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

input:

252 461
211122121121212111111222121212221122112221222222121122211112222221122221122121222121221221111222211112111212111122122212122211111221121111112111122111112212212121111222112121111211122211121221221222211122121112111112112122211111221222111122111111112121
111211122112112121212111211111112221111...

output:

838
21 22
251 252
249 251
240 242
242 244
244 246
246 248
248 250
239 241
241 243
234 236
236 238
238 240
240 242
242 244
244 246
246 248
233 235
232 234
234 236
236 238
238 240
240 242
242 244
244 246
230 232
232 234
234 236
236 238
238 240
229 231
223 225
225 227
227 229
222 224
224 226
226 228
22...

result:

ok good job!

Test #43:

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

input:

403 762
1121111121211222121112221221121121112122122211222212211122221221112211212221112212122122122122212211222222212211122121121112122211112222212211112211112122222111112121222211211122111211211112222112211111211111222122222222221112112122111122221211221212211221221112212211121122221221111222212221...

output:

581
1 3
400 402
7 9
5 7
398 400
12 14
10 12
8 10
6 8
396 398
13 15
395 397
14 16
12 14
10 12
8 10
394 396
16 18
14 16
12 14
10 12
392 393
20 22
18 20
16 18
390 392
21 23
388 390
22 24
20 22
18 20
387 389
389 391
24 26
22 24
20 22
385 387
387 389
25 27
380 382
382 383
28 30
26 28
24 26
379 381
35 37
...

result:

ok good job!

Test #44:

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

input:

76 510
2222111212221211121221222112212211112211122222112221211122211121122212122122
2122112112212212121222212122121222221221211211121212211122121221222211122111

output:

56
14 16
22 24
12 14
27 29
11 13
30 31
10 11
35 37
33 35
8 10
36 38
34 36
3 5
5 7
40 42
38 40
36 38
2 3
41 43
39 41
37 39
35 37
42 44
40 42
38 40
43 45
41 43
39 41
44 46
47 49
45 47
43 45
41 43
48 50
50 51
52 53
55 57
53 55
57 59
64 66
62 64
60 62
65 67
66 68
64 66
62 64
68 70
66 68
70 72
68 70
71 7...

result:

ok good job!

Test #45:

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

input:

336 811
2211111222112221111221212112121111111221121221112122121221212111211122222221222221222221222111121222212121221122222212212122121212122221112222222221121211111212222122122112112121112112211212212122211212222111212212211211222122212222212211221211221212112111122221212111221112111121111122222122...

output:

896
6 8
147 149
19 20
146 148
22 23
145 146
23 25
15 17
17 18
26 28
14 16
36 38
34 36
32 34
10 12
37 39
35 37
33 35
31 33
29 31
27 29
9 11
40 42
38 40
36 38
34 36
2 4
42 44
40 42
38 40
36 38
1 2
43 45
41 43
39 41
37 39
35 37
33 35
31 33
29 31
47 49
45 47
43 45
41 43
39 41
37 39
35 37
33 35
49 51
47 ...

result:

ok good job!

Test #46:

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

input:

363 525
1121111112211122212122112212112111112212221221121112111112212212212221121121122212221111111111212112212122211122211222111121122122122121112222111121121111111211212211112221121112112112111211222112112122112212221212212221112222122211221221112212111222212222111122222221222122221212112111212121...

output:

532
1 3
331 333
8 10
6 8
330 332
9 11
7 9
5 7
3 5
299 301
301 302
13 15
11 13
9 11
7 9
5 7
298 300
14 16
12 14
10 12
297 299
299 301
15 17
291 293
293 295
295 296
17 19
289 291
291 293
19 21
287 289
289 291
291 292
20 22
18 20
16 18
14 16
283 285
23 25
280 282
282 284
24 26
22 24
20 22
278 280
280 2...

result:

ok good job!

Test #47:

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

input:

134 452
22111112221112112112222121221222212222212221112222112212122221222121112212112221122212212121121122221212111211111221221221122122121112
21221111122111211222122122222221222221111122211222112122122122122122112112211121122212211221211112212121122222212211121212221122221112

output:

105
6 8
4 6
127 129
19 21
125 127
26 28
121 123
28 30
120 122
29 31
118 120
30 32
117 118
31 33
108 110
110 111
33 35
104 106
106 108
108 110
34 36
102 104
104 106
106 108
108 109
35 37
100 102
102 104
104 106
106 108
36 38
99 101
101 103
103 105
105 107
37 39
98 100
100 102
102 104
104 106
113 115
...

result:

ok good job!

Test #48:

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

input:

134 865
22212222211222112122112221122122221111121221112211122121112211222212121222222122222112212122212122111121221221121222112212212212112222
22122112121212112121121112222222122212112221221222122222111111221211122212122121222212221221222222212112112222122211211112221112121222

output:

126
46 47
92 94
50 52
89 90
51 53
49 51
87 88
53 55
52 53
83 85
85 87
57 59
55 57
53 55
82 84
58 60
56 58
54 56
81 83
61 63
59 61
57 59
55 57
80 82
62 64
60 62
58 60
56 58
79 81
63 65
77 79
64 66
75 77
66 68
43 45
71 73
42 43
96 98
40 42
101 103
99 101
34 36
36 38
103 105
101 103
33 35
35 37
37 39
3...

result:

ok good job!

Test #49:

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

input:

274 107
2212222112221112121222212212122212121112121212122111221221221111211211222211211211111122112222112112122122222211222111211222212221121122112211121211112221221121221111212222121211122111222212221222211112122222111212211111112121112222222221212222112222211122211222121111121122
22122212111121221...

output:

682
49 51
55 57
48 50
50 52
57 59
46 48
48 50
58 60
44 46
46 48
48 49
63 65
61 63
59 61
42 44
44 46
46 48
66 68
64 66
62 64
40 42
42 44
44 46
69 71
67 69
65 67
63 65
61 63
36 38
38 40
40 42
42 44
44 45
70 72
68 70
34 36
36 38
38 40
40 42
42 43
71 73
69 71
32 34
34 36
36 38
72 74
31 33
33 35
35 37
75...

result:

ok good job!

Test #50:

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

input:

414 808
2121221211222112211122122222211112211121122211221122212121222222222222212111121212122112111112121111222222111212122122122222211211112121221221111211121112221112121112122212112222212212122221222222121211112122212212211111222212112112112111221221222121222112112211222121222121122122111121211212...

output:

971
346 348
345 346
359 360
347 349
340 342
350 352
348 350
346 348
338 340
351 353
349 351
330 332
352 354
351 352
326 328
354 356
353 354
325 327
327 329
329 331
356 358
355 356
318 320
320 322
322 324
324 325
361 362
316 318
318 320
320 322
364 366
363 364
314 316
316 318
318 320
367 369
365 367
...

result:

ok good job!

Test #51:

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

input:

482 170
1121222222122111121212122122122212121122112211212221211221221222211221211212112222122121121212211111111221112221122112111222212221211112221122222121122222121211121111121221121121112111112222112221122212111211122212111111221112221112121211212112122111121221112121212221122221211222222211111211...

output:

978
2 3
481 482
3 5
475 477
4 6
474 475
5 7
6 8
7 9
8 10
10 12
11 13
16 18
14 16
12 14
18 20
16 18
14 16
13 14
20 22
18 20
16 18
14 16
22 24
20 22
18 20
16 18
23 25
21 23
19 21
17 19
15 17
25 27
23 25
21 23
19 21
17 19
26 28
24 26
22 24
20 22
18 20
28 30
29 31
27 29
25 27
23 25
21 23
30 32
37 39
35 ...

result:

ok good job!

Test #52:

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

input:

117 25
112212222221112122221111222222122211212111122122111121122211121211121222122221122111111211222122221221211121222111222
111122222122122111222212111122112222211121122212122212212211111121112222122212112121211222111112221211112112221222222

output:

78
24 25
111 113
113 114
52 53
110 112
54 56
109 111
111 113
55 57
107 109
109 110
57 58
103 105
105 107
107 109
60 62
58 60
101 103
103 105
89 91
87 89
85 87
100 102
102 104
104 106
106 108
90 92
98 100
91 93
89 91
97 98
95 97
81 83
80 81
77 78
68 69
64 65
48 50
47 49
49 51
44 46
46 48
39 41
34 36
...

result:

ok good job!

Test #53:

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

input:

344 865
1111222222222122212121112221111122221122111221111112222122112112111211221222222221211111121121211222121122112222121112212222212221111121122221222111211112212111121222211111121111221122121122112112212221122221222121222121222221212221221122211111111211121112121212212112112222122121111122212212...

output:

505
3 5
2 3
339 340
69 71
67 69
65 67
63 65
334 336
336 338
70 72
333 335
335 336
73 75
71 73
69 71
331 333
333 335
89 90
330 332
91 93
328 330
94 95
327 328
96 98
323 324
97 99
303 305
305 307
98 100
298 300
300 302
302 304
304 305
100 102
296 298
298 300
300 302
108 110
295 297
297 299
299 301
301...

result:

ok good job!

Test #54:

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

input:

416 266
1122121211112212122212111111222122221212211112211122211222222112212211121221121212112211211111222222211212111222121112111112211212111221212112222122112222211112122121111111211111211121212111212111121121212121221122222221222222121221212221111212121212212212212212211121121222211111112112121122...

output:

837
1 3
401 402
2 4
399 400
4 6
3 4
397 399
6 8
5 6
394 396
396 398
11 13
9 11
7 9
391 393
393 395
395 397
12 14
10 12
8 10
6 8
389 391
14 16
12 14
10 12
8 10
388 390
390 392
392 394
394 396
16 18
14 16
12 14
11 12
387 389
17 19
15 17
13 15
383 385
385 387
19 20
382 384
384 386
386 388
20 22
377 379...

result:

ok good job!

Test #55:

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

input:

122 942
11212212222212221121121211211221222121122222221111121111122222222122212111221222112112111112112221121211221111221212221221
11122212121221112122222112111122211222121111111222222222122111211222121212211121221221121112212222221212112111221212212211

output:

120
56 58
96 98
58 60
92 94
94 96
103 105
101 103
99 101
86 88
88 90
90 92
104 106
83 85
85 87
87 89
89 91
91 93
109 111
107 109
80 82
82 84
84 86
86 88
111 112
79 81
81 83
83 85
112 114
78 80
80 82
82 84
114 116
76 78
78 80
80 82
116 118
75 77
77 79
79 81
119 121
71 73
73 75
75 77
77 79
69 71
71 73...

result:

ok good job!

Test #56:

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

input:

45 417
111112112221111122222222221212211212112122121
212122222212121122211111211211121221122121122

output:

55
4 6
2 4
1 2
44 45
7 9
5 7
3 5
42 44
8 10
6 8
36 38
9 11
7 9
5 7
31 33
33 35
15 17
13 15
11 13
9 11
7 9
30 32
16 18
14 16
12 14
10 12
8 10
17 19
15 17
13 15
11 13
9 11
18 20
16 18
14 16
12 14
10 12
19 21
17 19
20 22
18 20
16 18
14 16
12 14
21 23
19 21
22 24
20 22
18 20
16 18
14 16
24 26
22 24
20 2...

result:

ok good job!

Test #57:

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

input:

440 881
1111221112211221121112222212222122221122112221212122121122212221111221221221222212121112112121112221122112112212212211212121122112112112121211221112112221111121121111112112121222212112222112222122221121212112222211111212211222221221111221112221212212122112111212112211211211221112211121222222...

output:

625
9 10
438 440
12 14
10 12
435 437
437 439
13 15
429 431
431 433
433 435
435 437
16 18
15 16
427 429
429 431
431 433
20 22
18 20
16 18
426 428
428 430
430 432
432 434
21 23
19 21
17 19
418 420
420 422
422 424
424 426
22 24
20 22
416 418
418 420
420 422
23 25
21 23
415 417
417 419
419 421
421 423
4...

result:

ok good job!

Test #58:

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

input:

284 884
21111212121111112111222121122122212122111222212122212211221121211111212211121222112222122212122121211112121122222122222211111112111122212222122221111121221212222221221212221111212211111121111211111222112221212121122112211211111222211122221121121222111212211111122221111121111122211211
1112122...

output:

794
7 8
282 284
15 17
13 15
11 13
279 280
19 21
17 19
15 17
13 15
277 279
20 22
18 20
16 18
14 16
271 273
273 275
21 23
19 21
265 267
267 269
269 271
271 273
23 25
264 266
266 268
268 270
270 272
272 274
274 276
26 28
24 26
22 24
263 265
265 267
267 269
27 29
26 27
262 264
264 266
266 268
268 270
27...

result:

ok good job!

Test #59:

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

input:

422 324
1122222121221221121221212122111112212121211222221221212112222221112112212211111221112221222212122122211121121111211111221222122221122121122221122221221221122122222212222121111121211212222121222222111112212111112221221112111111121122111221121222222112211211222212222121122112221121111112112212...

output:

888
1 3
420 422
3 4
418 420
111 113
109 111
413 415
415 417
417 419
117 119
411 413
413 415
118 120
116 118
114 116
112 114
110 112
410 412
412 414
414 416
416 418
120 122
118 120
116 118
114 116
409 411
121 123
119 121
408 410
410 412
412 414
414 416
122 124
403 405
405 407
407 409
124 126
402 404
...

result:

ok good job!

Test #60:

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

input:

247 857
1112211211222111211122112111221222122212221111212121121212221211112122222111221211121121121122221211112221221122121212222122122111212112121211221112112111211222211221122221112222222111122112221122111111121111111211112122112121122211212212121122221
22111112221122221222211122212211112111221111...

output:

583
2 4
246 247
3 5
1 3
240 241
9 11
233 234
10 12
229 231
15 17
225 227
227 229
19 21
223 225
225 227
20 22
18 20
16 18
14 16
220 222
23 25
21 23
219 221
221 223
223 225
27 29
25 27
217 219
219 221
28 30
26 28
24 26
22 24
20 22
18 20
16 18
204 206
206 208
208 210
30 32
28 30
26 28
24 26
22 24
20 22...

result:

ok good job!

Test #61:

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

input:

272 376
22221122111211111222211222221222212122221221111222212222222122211212112222111121222211222221222212121221112122211211221221112111111212121212211122222122222221222222211112121221212211221122222111222221111121211221112221211112122221222121211211211212111121222122111111122111
2222211111111222212...

output:

586
5 7
269 271
271 272
16 18
260 262
262 264
17 19
259 261
261 262
19 21
257 259
23 24
256 258
139 141
255 257
143 145
141 143
253 255
144 146
142 144
248 250
250 252
252 254
254 256
145 147
246 248
248 250
250 252
252 254
146 148
144 146
243 245
245 247
247 249
249 251
251 253
147 149
240 242
242 ...

result:

ok good job!

Test #62:

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

input:

456 295
1221111112111221222222121212221222112212111112212221212122122122122211211211122122222212221211122222212211111212121111122222112212121211221121212221122112111221211122121121212121212112122112221122211212111221221211221122211111221211221112221122111112111121222121112112112221222221211122221112...

output:

952
8 10
6 8
161 163
163 164
12 14
10 12
8 10
7 8
159 161
13 15
11 13
9 11
158 160
15 17
13 15
154 156
16 18
14 16
12 14
10 12
151 153
153 155
155 157
18 20
16 18
150 152
152 154
154 155
27 28
147 149
149 151
151 153
28 30
146 148
30 32
145 147
31 33
143 145
145 146
32 34
141 143
35 37
33 35
138 140...

result:

ok good job!

Test #63:

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

input:

463 947
1111221121222222122211112221111122122112211211211211222221121112121121122222211121121122221212212122112121212112111112112222211222121121121111111211121121111111112222112121221121122112111211222221122221222112111221212122221211221111221211222121221111221111222111212122111111121212222111112221...

output:

1304
3 5
57 59
59 61
4 6
56 58
7 9
5 7
55 57
57 59
9 11
8 9
53 55
10 12
50 52
31 33
47 49
49 51
33 34
44 46
46 47
34 36
27 29
35 37
26 28
38 40
20 22
22 24
62 64
19 21
21 23
64 66
18 20
20 21
67 69
65 67
16 18
18 20
70 72
68 70
15 17
17 19
72 74
14 15
82 84
80 82
78 80
85 87
83 85
86 88
87 89
85 87
...

result:

ok good job!

Test #64:

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

input:

242 384
11212222111222212221111221121211122111212121221121112222122212112222212112112222221112211222112221211221112112212121212122121212211211222212111111221221211211122212122211112212112222221221212112111212222222212121212122211111121121222222112211
2111112111211212221221112211112212112211212221222...

output:

222
1 3
240 242
51 53
219 221
221 223
53 54
218 220
220 222
222 224
54 56
217 219
56 58
215 217
217 218
57 59
213 215
215 217
58 60
211 213
213 215
215 216
60 62
209 211
211 213
213 215
63 65
207 209
209 211
211 213
64 66
206 208
208 210
210 212
212 214
65 67
205 207
207 209
209 211
70 71
204 206
20...

result:

ok good job!

Test #65:

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

input:

256 235
2122221122211122222211121122211121221212112122111121221212121122221112222111121122121221222122122221121111122221222221212112121112122121212222222111111222121111222121212212112221222122121221121111121211122222122121222111111122121112212221122211122122122221
21111112221121221112112212111122221...

output:

391
80 82
254 256
83 84
252 254
84 86
250 252
85 87
249 251
87 89
247 249
88 90
86 88
246 248
248 250
89 91
242 244
244 246
246 248
91 93
241 243
243 245
245 247
92 94
90 92
240 242
242 244
244 246
94 96
237 239
239 241
241 243
95 97
93 95
236 238
238 240
240 242
242 244
96 98
235 237
237 239
239 24...

result:

ok good job!

Test #66:

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

input:

464 855
1112211221222222211221211111121111222222121212122122212211221211221222122222111121122111221221111112212111112122221122222212212212222212221211122211121121122221222112121112212212222121222221112211221212211121121221212121222212211212121122212212121111111222111211222222221112212111212122222112...

output:

1327
2 4
1 2
456 458
3 5
455 457
6 8
4 6
2 4
452 454
454 456
29 30
448 450
450 452
452 454
33 35
31 33
447 449
449 451
451 453
453 455
34 36
32 34
446 448
448 450
450 452
36 37
444 446
58 59
443 445
445 447
447 449
449 451
87 89
441 443
443 445
89 90
440 442
91 93
439 441
441 443
98 100
96 98
438 43...

result:

ok good job!

Test #67:

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

input:

321 947
1211121122121112121121212222111212112211121222222212221222121121111122212122221222121111211122112221111122221121122221122122121122212221122121222211112111112212112211221111211111211222212212112222221111221111122211121212212212112211121121221221122222222112112111112221212211211211122211211112...

output:

392
4 6
3 4
295 296
8 10
6 8
292 294
14 16
13 14
287 289
289 291
291 293
16 18
284 286
286 288
19 21
17 19
15 17
283 285
285 287
287 289
289 291
21 23
19 21
282 284
23 25
21 23
278 280
280 282
24 26
22 24
20 22
275 277
277 279
279 281
281 283
283 285
25 27
23 25
272 274
274 276
26 28
24 26
271 273
2...

result:

ok good job!

Test #68:

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

input:

268 726
1111222212222222121122221211122121122221112222222121212122211211212121221221112122121222111221222112111212122121212121221111122122111222122212112121121121112221111212212221122212112111221122221222112221121212221211221111112111112121222212122112112222122212212121212212
11112112111221211121221...

output:

497
198 200
216 218
200 201
215 217
217 219
227 229
225 227
212 214
214 215
229 231
210 212
212 214
231 233
209 211
232 234
230 232
228 230
226 228
224 226
222 224
220 222
208 210
210 212
233 235
206 208
234 236
232 234
230 232
228 230
226 228
204 206
206 207
236 238
234 236
232 234
230 232
228 230
...

result:

ok good job!

Test #69:

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

input:

159 708
112122221111122221211112111122111111121111222212111112111122112222112211111112111112221211111212122111221121222111111222211122122122222111211212222122111121112
111122211211121211121211111111122211112112122222212212211111211212111122121212212112122211212221111211221122111211122222112222111212...

output:

235
52 54
70 72
57 59
55 57
53 55
51 53
69 71
58 60
56 58
54 56
45 47
47 49
61 63
59 61
57 59
55 57
43 45
45 47
63 65
61 63
38 40
40 42
76 78
74 76
30 32
32 34
82 84
80 82
78 80
76 78
29 31
31 33
33 35
35 37
37 39
39 41
41 43
43 45
83 85
81 83
79 81
24 26
26 28
28 30
30 32
84 86
82 84
80 82
78 80
19...

result:

ok good job!

Test #70:

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

input:

252 78
221121122112221221111121211112121221121212221211212111111111112212122111111212212112212221122111122212222211212122211111111211112111111121122121211121211212122212121212211222122212211111121122111112212211112122112222121112221221112222112111221212222112
1221122222111112121112211111121222111221...

output:

580
7 9
249 250
10 12
247 249
11 13
9 11
51 53
53 55
61 63
59 61
57 59
49 51
51 53
62 64
60 62
46 48
48 49
64 66
62 64
44 46
46 47
66 68
64 66
40 41
67 69
65 67
63 65
61 63
59 61
35 37
37 39
74 76
72 74
70 72
68 70
66 68
25 27
27 29
29 31
31 33
76 78
74 76
72 74
17 19
19 21
21 22
77 79
75 77
73 75
7...

result:

ok good job!

Test #71:

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

input:

188 305
12222121122111121122222211222211221212112122212112112212112221212122222111122111121111111111221111122112122212211122222112112221111211211221112111122111111221212221212212112112112222122222
2122112122111211221122221211212211121212112122211111112121222212121211121222222211212111111222112112212...

output:

194
1 2
127 129
129 131
18 19
122 123
98 100
97 98
119 120
102 104
100 102
110 112
104 106
103 104
108 110
113 115
107 108
114 116
82 84
84 86
86 88
88 90
90 92
116 118
77 79
79 81
81 83
83 85
133 135
76 78
78 80
136 138
71 73
73 75
75 77
77 79
79 81
81 83
138 139
70 72
72 74
74 76
76 78
141 143
69 ...

result:

ok good job!

Test #72:

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

input:

451 381
2122121211221222121122122211122222122222221212222112211121211212221211222212112222121212112122222211212211212121222221121211212211121121211222211112122221122221212121222212211221211112222121122111211212111121111221112222122221121111222121212211121121122222111122112111211212122121212221221222...

output:

849
2 3
430 431
323 325
425 427
325 327
423 425
326 328
421 423
333 335
420 422
422 424
424 426
335 336
418 420
420 422
422 424
336 338
415 417
417 419
419 421
337 339
412 414
414 416
416 418
338 340
411 413
413 415
415 417
417 419
339 341
410 412
412 414
343 345
341 343
407 409
409 411
411 413
413 ...

result:

ok good job!

Test #73:

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

input:

239 584
22211122211121121212121122121112121121222121222212111211212211212111112211222221122122212221221222212221212112221221122221212222122221111122122121122212221112221122121221122121221111121212221212221111221221111222221211212221111212222222221
2221212221212211222111212222121221121111122211212121...

output:

333
5 7
178 180
7 9
177 179
179 181
181 183
11 13
9 11
175 177
177 179
14 16
12 14
11 12
173 175
175 177
16 18
14 16
13 14
172 174
174 176
176 178
18 20
16 18
14 16
168 170
170 172
172 174
174 176
20 22
18 20
17 18
166 168
168 170
23 25
21 23
19 21
164 166
24 26
22 24
20 22
18 20
163 165
165 167
26 ...

result:

ok good job!

Test #74:

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

input:

331 115
1212121111112121121121121211112211211111111111221212111122211222222111212222112122212211222221121221111221122111121212212211112211112121221122211222222222212121212111122112112111112121121222122111221221122112122211221211221122211212121121221121122212112212211111222221221122112222212111122122...

output:

1090
2 3
11 13
9 11
7 9
5 7
13 15
11 13
9 11
16 18
14 16
12 14
19 21
17 19
15 17
13 15
22 24
20 22
18 20
16 18
14 16
24 26
22 24
20 22
18 20
16 18
29 31
27 29
25 27
23 25
30 32
28 30
26 28
24 26
22 24
33 35
31 33
29 31
27 29
25 27
45 47
43 45
41 43
39 41
37 39
35 37
33 35
31 33
29 31
27 29
46 48
44 ...

result:

ok good job!

Test #75:

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

input:

484 949
2222111221121222111212122122222111112222221112111111211122211221112222212122111221121221222112212122211222212222121222221121222122122221121111111221112112111111211212112122212212211212122111212122111212111221112112121212121212211211122112112121211211121221111122211121212211212211222111212222...

output:

1354
162 164
160 162
483 484
164 166
154 156
156 158
167 169
165 167
151 153
153 155
155 157
157 159
169 171
167 169
147 149
149 151
151 153
153 155
155 157
170 172
168 170
166 168
146 148
148 150
150 152
152 154
154 155
171 173
138 140
140 142
142 144
144 146
146 148
148 150
150 152
173 175
135 137...

result:

ok good job!

Test #76:

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

input:

463 392
2222111122111122222112221221121122222222211221111122111222111211211221112221212211122122121221212211222121111221212222112221222112221212211122222122221112211211112111122111121222122211222221221222212212111111222112221222212122121212222222112112122112122211221221211222211121111122121122212122...

output:

1152
13 15
453 455
455 457
14 16
12 14
452 454
454 456
456 458
458 460
15 17
451 453
453 455
16 18
450 452
452 454
20 22
18 20
449 451
451 453
21 23
448 450
450 452
22 24
20 22
446 448
448 450
24 26
444 446
446 448
448 449
25 27
440 442
442 444
444 446
446 448
28 30
26 28
436 438
438 440
440 442
442...

result:

ok good job!

Test #77:

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

input:

170 178
11111222222112212112122221111222221221121221221211221211112111112221212111221111121121222212212112212111121211211112212221221111221122221122111111211211222221211111112211
1212212221212211211221111111121122212211111121212121121221221121221112122212111112112222112221121112121212221111211121112...

output:

294
4 6
2 4
168 170
5 7
167 169
6 8
4 6
159 161
161 163
163 165
165 167
167 168
7 9
157 159
159 161
161 163
163 165
165 167
8 10
156 158
158 160
160 162
162 164
164 166
9 11
155 157
157 159
159 161
161 162
12 14
11 12
154 156
156 158
158 160
13 15
153 155
155 156
18 20
16 18
14 16
150 152
152 154
20...

result:

ok good job!

Test #78:

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

input:

52 833
1122211111222221122222221221122212212122221211121122
1221122111221212122111212122112222221122222121212222

output:

50
2 4
48 50
9 11
7 9
44 46
46 48
48 49
11 13
42 44
44 46
46 47
41 43
43 45
40 42
39 41
41 43
37 39
39 41
35 37
37 39
34 36
36 38
38 40
32 34
34 36
31 33
33 35
30 32
32 34
27 29
29 31
31 33
26 28
28 30
30 32
24 26
26 28
23 25
25 27
27 29
29 31
22 24
24 26
26 27
21 23
23 25
20 22
22 23
15 16
5 6

result:

ok good job!

Test #79:

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

input:

289 337
2212212212211212221122222221211112121121212121221121222112212121121222122122121112212222212121221212121222111112222111211111121112222211111121212221222211221212111121111221121211112121122222121212211212121112111112212221211212112211112111122222221121111111112212212211222221211221122112111
22...

output:

714
180 181
283 285
285 287
287 289
181 183
282 284
184 186
279 281
281 283
283 285
185 187
183 185
278 280
280 282
282 283
203 204
275 277
277 279
206 208
205 206
197 199
199 201
212 214
210 212
208 210
196 198
213 215
211 213
209 211
207 209
194 196
196 197
215 217
213 215
211 213
192 194
194 196
...

result:

ok good job!

Test #80:

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

input:

275 642
22211221221111122222212111222212222111212212211221211111121221112222211211211112122212211121112121212212121112222112122122121112121222211221122212212222211211111221212212122212112122112222222212111211121121211112111121121212122211111121122212222211211122211112211111122111221
2112111111222121...

output:

628
252 253
274 275
271 273
270 271
261 263
263 265
265 267
255 257
257 259
249 251
246 248
248 250
245 247
247 249
244 246
243 245
245 247
242 244
240 242
239 241
241 243
243 245
238 240
235 237
237 239
228 230
230 232
232 234
234 236
236 238
227 229
229 231
231 233
233 235
235 237
226 228
228 230
...

result:

ok good job!

Test #81:

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

input:

274 934
1112211122121111121221212211111121111211221222212222121222112121212211212111222221121211111221112122221212222212212112222121122221121212212122121112211212111221221112112221222122121212111112221211212122212221122222111111112121211121211212122212221111111121111221212221121221
22221212122111111...

output:

457
2 4
260 262
262 264
3 5
1 3
255 257
257 259
7 9
5 7
3 5
246 248
248 250
250 252
252 254
254 256
8 10
6 8
4 6
245 247
247 249
249 251
251 253
253 255
255 257
10 12
8 10
6 8
244 246
246 248
248 250
250 252
16 18
14 16
12 14
10 12
8 10
242 244
244 246
246 248
248 250
18 20
16 18
14 16
12 14
10 12
2...

result:

ok good job!

Test #82:

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

input:

230 182
21112111222221222221121121121111212221112112111122212222212111121221211222222212121122112211212211211122221221111111221121222221122112221111111212211121111122121111121212122122211111222211221111222122222222111221112112211221111122
1212122111122212122221212221211212112222122222122211111112211...

output:

286
4 5
223 225
7 9
151 153
153 154
8 10
6 8
147 149
26 28
146 148
148 150
150 152
31 33
29 31
27 29
144 146
146 147
33 35
31 33
29 31
136 138
138 140
140 142
142 144
144 145
34 36
32 34
135 137
137 139
139 141
141 143
35 37
34 35
134 136
136 138
138 140
140 142
39 41
37 39
131 133
133 135
135 137
1...

result:

ok good job!

Test #83:

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

input:

317 182
2122212211212111112112122222122121121111222211222112122222112112111111121112112111211211222112212111112221112122222222211211121121212121122211211121122211121111212211212222121111212122112122122221112112122122221211121111122112212212122221111222121112212211221121221122211122122212112212211111...

output:

1194
10 11
58 60
60 62
20 22
18 20
16 18
57 59
22 24
20 22
18 20
55 57
23 25
21 23
49 50
24 26
22 24
13 14
25 27
23 25
8 9
27 28
4 6
28 30
1 2
29 31
31 33
34 36
32 34
39 41
37 39
35 37
33 35
40 42
38 40
36 38
41 43
39 41
38 39
42 44
40 42
45 47
43 45
51 52
53 54
70 72
68 70
74 76
72 74
70 72
77 79
7...

result:

ok good job!

Test #84:

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

input:

348 517
2221222112221121121122221221111221121112221121121122121112122111121112112111122222221122221111211121221112211112112222222122211211122212112212111211121222121121121121112212122111212122122221221222211122111221212111212111212211222222111111212221211122221121222111211112111111221222122121211112...

output:

743
110 112
344 345
113 115
111 113
341 342
115 117
113 115
330 332
117 119
115 117
329 331
331 333
346 347
324 326
322 324
319 321
321 323
323 325
317 319
319 321
321 323
316 318
318 320
320 322
315 317
317 319
319 321
313 315
315 317
312 314
314 316
316 318
318 320
311 313
313 315
309 311
311 313
...

result:

ok good job!

Test #85:

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

input:

90 971
111221112211121212221112212221121221122112111221111221121112212221222121121121111221221122
122221212112211122111222111121111221222111112122122112111122121122111112212211121212212222

output:

64
2 4
86 88
3 5
85 87
7 9
5 7
83 85
8 10
6 8
4 6
82 84
12 14
10 12
8 10
7 8
77 79
79 81
81 82
14 16
12 14
10 12
9 10
74 76
76 78
78 80
16 18
14 16
12 14
71 73
73 75
75 76
17 19
15 17
13 15
69 71
71 73
73 75
18 20
68 70
70 72
22 24
67 69
69 71
71 73
23 25
21 23
19 21
17 19
64 66
25 27
23 25
46 48
26...

result:

ok good job!

Test #86:

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

input:

438 523
1112121212111122111121111122112111212111221211221121112122211121221211111222222222221111222122221112122111122121111221111221121112211221222221121211222121222122222121211122212212221211122111222122111222221222112221212212121112122222112221122211111121121221122111222121121111221212212121111211...

output:

1409
2 4
1 2
424 425
4 6
2 4
416 418
418 420
420 422
6 8
4 6
3 4
412 414
8 10
7 8
409 411
411 413
413 415
13 15
11 13
9 11
408 410
410 412
14 16
12 14
406 408
408 410
19 21
17 19
15 17
13 15
397 399
399 401
401 403
403 405
405 407
407 409
409 411
411 413
25 27
23 25
21 23
19 21
395 397
397 399
399 4...

result:

ok good job!

Test #87:

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

input:

81 478
112121122122121122121111111112212222211112211212212111122111211111112121212212121
122221121212121221112111212112111121111212121112112221121111211222121212122111211

output:

64
2 3
61 63
63 65
3 5
57 59
59 61
61 63
63 64
6 8
4 6
51 53
53 55
55 57
57 59
59 61
7 9
5 7
49 51
51 53
9 11
8 9
48 50
50 52
10 12
46 48
12 14
43 45
45 47
47 49
49 51
16 18
14 16
42 44
18 20
16 18
37 39
39 41
41 42
28 30
26 28
24 26
22 24
21 22
36 38
38 40
29 31
27 29
25 27
31 33
29 31
27 29
32 34
...

result:

ok good job!

Test #88:

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

input:

153 157
212111222111222211212221112211211122112111221111111121122211211111222211122122121111221122122121112121122221122121111111211221122121222221121222111222222
122122111122122121211111222211111122211212221211211221121111212222221121221212122221122222112111112212111212112211122112111122211122221111...

output:

263
5 7
39 41
41 42
6 8
36 38
38 40
12 13
35 37
51 53
49 51
31 33
33 35
35 36
54 56
52 54
50 52
48 50
46 48
27 29
29 31
31 33
33 35
55 57
53 55
23 25
25 27
56 58
54 56
52 54
22 24
24 26
65 67
63 65
21 23
23 25
66 68
64 66
62 64
60 62
58 60
56 58
16 17
67 69
65 67
9 11
68 70
66 68
64 66
1 2
72 74
70 ...

result:

ok good job!

Test #89:

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

input:

453 434
2212221211121122211222111221212222221112122122221112112121112111122121121122222221121222112122112122212221222121112121212222122112121122122222211211111111111112111122112212221221211111212112222221122212222211221211121222112212112211112112112211121121122212222112212211122121222112111221211111...

output:

789
65 66
442 444
70 72
68 70
439 441
441 443
443 445
73 75
71 73
434 436
436 438
438 440
74 76
73 74
431 433
433 435
435 437
437 439
439 441
441 443
158 160
428 430
430 432
432 434
434 436
436 438
163 165
161 163
426 428
428 430
430 432
432 434
434 436
164 166
162 164
160 162
425 427
427 429
429 43...

result:

ok good job!

Test #90:

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

input:

496 670
1211121111122111221111221111212212121212221122222212222121212121121121212111221112111112211112221211112121222122211221212222221212121122212222221112111221222222111112121222221111122222112221212212212112222221121211212112212122212222212121121221111222221121221111211111222211111221211212222122...

output:

1102
5 6
484 486
10 12
8 10
6 8
483 485
485 487
11 13
9 11
7 9
477 479
479 481
481 483
483 485
15 17
13 15
11 13
9 11
476 478
478 480
16 18
14 16
12 14
11 12
470 472
472 474
474 476
476 478
21 23
469 471
471 473
473 475
475 477
477 479
479 481
27 29
25 27
23 25
467 469
469 471
471 473
473 475
29 31
...

result:

ok good job!

Test #91:

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

input:

10 526
2221221221
2122221221

output:

1
2 4

result:

ok good job!

Test #92:

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

input:

180 555
221221211211221121121212212222211121122111122212112211122211222212211211221122221112212111212221121211212211122211121121122222111221121122221222211111121222212112222112112121121211
122111122212221122212221111111221112222122111222221121222211211112111211222122221121221112121112111222112222212...

output:

149
18 20
178 180
20 22
19 20
176 178
178 179
22 24
168 170
170 172
172 174
23 25
21 23
165 167
167 169
25 27
23 25
164 166
166 168
42 44
163 165
165 167
49 51
162 164
164 166
50 52
159 161
161 163
163 165
54 56
53 54
157 159
159 161
161 163
163 164
55 57
156 158
158 160
160 162
56 58
155 157
157 15...

result:

ok good job!

Test #93:

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

input:

489 819
2111111211211211121222211221221122121211111212121121111112112122121122222111212112212222212122211211112111121211221121121112212111211121212222121222111111112211112121121212122121212221211111121122212121112111222112211222122211221212121112211122121212112212112221121112112212211121222121221211...

output:

1457
9 11
477 479
12 14
11 12
475 477
16 18
14 16
12 14
474 476
476 478
18 20
16 18
14 16
13 14
470 472
472 474
24 26
466 468
468 470
25 27
460 462
462 464
464 466
466 468
28 30
455 457
457 459
459 461
461 463
463 465
465 467
467 469
469 471
31 33
453 455
455 457
457 459
459 461
461 463
463 465
465 ...

result:

ok good job!

Test #94:

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

input:

167 414
22222122212212121111122212211121121122211212121222112112221211221212222222212112121222222111211222121112112221111122212112111121212222222221122122122111112111222221121
2211211222111221212122222211122212211111221121111221222212221112122111222121121112222121221222122211121211122222221122212211...

output:

178
32 34
163 165
165 167
35 37
162 164
36 38
34 36
161 163
114 115
160 162
125 127
123 125
121 123
159 161
127 129
155 157
157 159
159 160
129 131
128 129
149 151
151 153
153 155
130 132
148 150
150 152
152 154
154 156
156 158
146 148
148 150
150 152
145 147
147 149
149 151
151 153
143 145
145 147
...

result:

ok good job!

Test #95:

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

input:

374 365
1222211122112221112112222212212111221111221111121212212221111122111222212211121111221211222111112121111221212212211122212212212211212211211111112111121121121122111212221121122121222222221211111222111112211121211122221111122112211211212221121122221112121121122112221111212111211111221111111112...

output:

595
12 13
188 189
66 68
137 138
67 69
134 136
68 70
133 135
135 137
70 71
131 133
133 134
72 74
128 130
81 83
127 129
129 131
95 97
125 126
97 99
110 111
102 104
100 102
91 93
93 94
103 105
102 103
90 92
108 109
86 88
115 117
63 65
116 118
114 116
57 59
59 61
117 119
56 58
58 60
60 62
119 121
55 57
...

result:

ok good job!

Test #96:

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

input:

469 834
1222211111122121211211122121221112112211121212211121112221111112122222111211111112222122111122222221222112121112212212121121121221122212122221121222121212221211122111122121212222112112222111221222212122211121221221222211222122112112211122122221222221112222122112211212122111112112212111221212...

output:

1007
22 24
464 466
23 25
462 463
25 27
24 25
417 419
27 29
415 417
417 418
28 30
413 415
415 417
32 34
407 409
35 37
33 35
406 408
408 410
36 38
403 405
405 407
40 42
402 404
404 406
406 408
42 44
400 402
402 404
404 406
44 46
398 400
400 402
402 404
45 47
43 45
41 43
39 41
37 39
394 396
396 398
49 ...

result:

ok good job!

Test #97:

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

input:

52 77
1121111121222122122121212111121121212121112222211112
1121211121111121222121112212212111212222121221111221

output:

32
7 9
5 7
47 49
49 50
9 11
37 38
41 43
40 41
35 37
42 44
33 35
44 46
30 31
51 52
25 27
27 29
23 25
18 20
20 22
22 24
24 26
26 28
16 18
18 20
20 22
22 24
24 26
15 17
13 15
12 14
14 16
16 18

result:

ok good job!

Test #98:

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

input:

334 345
2111211112211221121111211212121122221121222122221211112222221222111111211111111122222212211211111112212211111211211221111111211222112211212111122211121122112212121221111121221211122111211211111222222122121212121111211111112122212212221122111122112112212112212212221221222212222112211121222212...

output:

1168
4 5
301 302
24 26
71 73
73 74
79 81
77 79
75 77
64 66
66 68
68 70
70 72
80 82
78 80
63 65
65 67
67 69
81 83
79 81
62 64
64 66
66 68
82 84
80 82
60 62
62 64
64 66
83 85
59 61
61 63
63 65
65 67
84 86
82 84
58 60
60 62
62 64
86 88
85 86
57 59
59 61
61 62
87 89
56 58
58 60
90 92
88 90
86 88
55 57
5...

result:

ok good job!

Test #99:

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

input:

322 316
1121211111112222221211212112221112211222112211112111111121211212222222222111122211212122121212221212121221212111122221121112122121212111222212221112122221211221112212122111112122112112122112212211212112222111112111222112221111221222121221212212221212111212121221122112212211111122211111221211...

output:

759
1 3
319 321
4 5
308 310
310 312
11 13
9 11
7 9
5 7
306 308
308 310
310 311
12 14
10 12
8 10
304 306
306 308
14 16
12 14
299 301
301 303
303 305
305 307
22 23
296 298
298 300
300 302
302 304
304 306
23 25
294 296
296 298
298 300
300 302
302 304
304 305
26 28
290 292
292 294
294 296
296 298
298 30...

result:

ok good job!

Test #100:

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

input:

28 491
1122122221222111121112122222
2111212121222221121122222121

output:

16
1 3
13 15
21 22
12 14
22 24
11 13
23 25
9 11
24 26
8 10
10 12
25 27
7 9
27 28
6 7
4 5

result:

ok good job!