QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#445969#2810. Speedrunegypt_ioi2024_04#100 ✓261ms15380kbC++202.9kb2024-06-16 18:08:152024-06-16 18:08:16

详细

Subtask #1:

score: 21
Accepted

Test #1:

score: 21
Accepted
time: 25ms
memory: 13356kb

input:

1
1 1000
1 119
1 453
1 454
2 59
3 113
3 657
3 824
4 494
5 33
5 550
5 937
6 287
7 222
7 577
7 742
8 626
9 896
10 204
11 638
12 305
12 552
12 791
13 246
14 840
15 95
15 316
15 772
16 109
16 551
16 846
17 581
18 142
19 601
19 744
19 977
20 361
20 404
20 845
21 245
21 410
21 518
22 351
23 971
24 497
24 ...

output:

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

input:

2
1 1000 500
1
0
0
1
1
1
1
1
0
0
1
0
1
1
1
1
1
1
1
1
0
1
0
0
0
0
1
1
1
1
0
0
1
1
0
0
0
1
1
0
1
1
1
1
0
1
1
0
0
0
1
1
1
0
1
1
0
0
0
0
0
0
0
0
0
1
1
1
1
0
1
1
1
0
0
0
1
1
0
1
0
0
0
1
1
1
0
1
1
0
1
1
0
0
0
1
1
1
0
1
1
1
1
1
0
0
1
0
0
1
0
1
0
1
1
1
1
0
1
0
0
1
1
1
0
1
1
1
0
1
1
1
0
0
0
1
0
1
0
1
1
1
1
1...

output:

2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 249
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 510
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 240
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 945
2 2 1
2 2 2
2 2 3
2 2 4
...

result:

ok OK

Test #2:

score: 21
Accepted
time: 31ms
memory: 14896kb

input:

1
1 1000
1 723
1 992
2 372
2 542
3 692
4 692
5 693
5 807
6 390
6 829
7 692
8 692
9 692
10 692
11 692
12 692
13 692
14 692
15 228
15 844
16 692
17 419
17 663
18 692
19 105
19 930
20 692
21 324
21 974
22 692
23 366
23 525
24 692
25 195
25 641
26 692
27 434
27 734
28 692
29 692
30 332
30 540
31 692
32 ...

output:

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

input:

2
1 1000 856
0
0
1
0
1
1
0
1
0
1
1
1
0
1
1
0
1
1
1
0
0
1
0
0
1
0
0
1
1
0
0
0
1
1
1
0
1
0
0
0
1
0
0
1
1
0
1
0
1
0
1
1
1
1
1
0
0
1
1
0
0
1
1
0
0
1
0
1
0
0
1
0
0
0
0
1
1
0
1
1
0
1
1
0
1
1
1
1
1
0
0
1
0
0
1
1
0
0
1
1
0
1
1
0
1
0
0
1
0
1
0
1
0
0
1
0
0
1
0
0
1
1
1
1
1
1
1
0
0
1
1
1
1
1
0
1
0
0
1
0
1
0
1
0...

output:

2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 692
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 237
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 100
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 139
2 2 1
2 2 2
2 2 3
2 2 4
...

result:

ok OK

Test #3:

score: 21
Accepted
time: 38ms
memory: 13568kb

input:

1
1 1000
1 14
1 139
1 817
1 975
2 840
2 993
3 207
4 367
4 847
4 977
5 18
6 9
6 667
7 135
7 389
7 474
7 595
8 296
8 535
9 970
10 337
11 648
11 899
12 266
12 414
13 207
13 922
14 620
14 936
15 44
16 984
17 459
17 825
17 902
18 511
18 535
19 872
20 522
20 717
21 234
21 426
21 515
21 609
22 488
22 869
2...

output:

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

input:

2
1 1000 938
0
1
0
1
0
1
0
1
0
0
1
0
0
1
1
0
0
1
0
1
1
1
1
1
0
0
1
0
1
1
1
1
1
1
1
1
1
0
0
0
0
1
1
1
0
1
1
1
1
1
0
1
1
0
1
1
1
1
1
1
0
1
1
1
0
1
1
1
1
1
1
0
0
0
0
1
1
1
0
1
1
0
0
0
1
1
0
1
0
1
1
1
1
1
1
0
0
1
1
1
0
0
1
1
0
0
1
1
1
1
1
1
1
0
0
1
0
0
0
1
1
0
0
0
0
0
1
0
0
1
0
1
0
1
1
0
0
0
1
1
0
0
1
0...

output:

2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 170
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 844
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 979
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 783
2 2 1
2 2 2
2 2 3
2 2 4
...

result:

ok OK

Test #4:

score: 21
Accepted
time: 91ms
memory: 13548kb

input:

1
1 1000
1 504
1 638
1 792
1 941
2 133
3 664
4 188
4 341
4 685
5 385
5 561
5 881
6 961
7 413
7 584
7 906
7 907
8 662
9 267
9 320
9 606
9 627
10 795
10 926
11 45
11 88
12 926
13 202
13 435
13 621
13 872
14 570
14 598
14 656
14 821
15 880
16 26
16 171
16 765
16 910
17 347
18 980
19 419
20 74
20 294
20...

output:

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

input:

2
1 1000 84
1
0
0
0
1
0
1
0
0
0
1
1
0
0
1
0
1
1
0
0
1
1
0
0
1
1
1
0
1
0
0
0
1
0
0
0
1
1
1
1
0
1
0
1
1
0
1
1
1
0
0
0
0
0
1
0
0
1
0
1
1
1
0
1
1
1
1
1
1
1
0
0
1
1
1
1
1
1
1
0
1
0
0
1
1
0
0
1
0
1
0
0
0
0
0
0
1
1
1
1
0
0
1
0
0
0
1
0
0
1
1
1
1
1
0
1
1
0
0
1
1
1
0
0
0
1
0
1
1
0
1
1
1
1
0
1
0
1
0
1
1
1
1
1
...

output:

2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 81
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 617
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 92
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 376
2 2 1
2 2 2
2 2 3
2 2 4
2 ...

result:

ok OK

Subtask #2:

score: 8
Accepted

Test #5:

score: 8
Accepted
time: 19ms
memory: 15292kb

input:

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

output:

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

input:

2
2 1000 651
1
0
1
0
0
0
0
1
0
0
1
1
0
0
0
0
0
0
0
0
0
1
1
0
1
0
0
0
0
1
0
0
1
0
1
0
0
0
0
0
0
0
0
1
0
1
1
1
1
0
0
0
0
0
0
0
0
1
1
0
0
1
0
0
0
0
0
0
0
1
1
1
0
1
0
0
0
0
0
0
0
1
1
0
1
1
0
0
0
0
0
0
0
1
1
1
1
1
0
0
0
0
0
0
0
1
1
0
0
0
1
0
0
0
0
0
0
1
1
1
0
0
1
0
0
0
0
0
0
1
1
0
1
0
1
0
0
0
0
0
0
1
1
1...

output:

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

result:

ok OK

Test #6:

score: 8
Accepted
time: 15ms
memory: 13872kb

input:

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

output:

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

input:

2
2 1000 577
1
0
0
0
0
0
0
0
0
0
1
1
0
0
0
0
0
1
0
0
1
1
0
1
0
0
0
0
0
0
0
0
1
0
1
1
1
1
0
0
0
0
0
0
0
0
1
1
0
0
1
0
0
0
0
0
0
0
1
1
1
0
1
0
0
0
0
0
0
0
1
1
0
1
1
0
0
0
0
0
0
0
1
1
1
1
1
0
0
0
0
0
0
0
1
1
0
0
0
1
0
0
0
0
0
0
1
1
1
0
0
1
0
0
0
0
0
0
1
1
0
1
0
1
0
0
0
0
0
0
1
1
1
1
0
1
0
0
0
0
0
0
1
1...

output:

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

result:

ok OK

Subtask #3:

score: 19
Accepted

Test #7:

score: 19
Accepted
time: 261ms
memory: 13576kb

input:

1
3 1000
1 20
1 569
2 69
2 72
3 510
3 811
4 278
4 994
5 890
5 918
6 97
6 577
7 11
7 791
8 138
8 653
9 219
9 539
10 22
10 151
11 527
12 195
12 420
13 187
13 293
14 265
14 476
15 594
15 988
16 424
16 881
17 407
17 613
18 178
18 471
19 400
19 896
20 95
21 221
21 949
22 624
23 247
23 361
24 140
24 169
2...

output:

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

input:

2
3 1000 986
0
0
1
1
0
1
0
0
1
0
1
0
1
1
0
1
1
0
1
1
0
1
0
0
0
0
0
0
0
1
0
0
1
1
0
0
0
1
0
1
0
1
1
1
0
1
0
1
0
1
1
1
0
0
1
1
0
0
1
0
1
0
1
0
1
1
1
1
0
0
0
0
0
0
1
0
1
1
0
0
1
0
1
0
0
1
1
1
1
0
0
0
1
1
1
1
0
1
1
0
0
0
0
1
1
0
0
0
1
1
1
0
1
0
0
0
0
0
1
0
1
0
0
0
1
0
1
1
1
1
0
1
0
0
0
0
1
0
0
1
0
0
1
0...

output:

2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 300
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 438
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 128
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 849
2 2 1
2 2 2
2 2 3
2 2 4
...

result:

ok OK

Test #8:

score: 19
Accepted
time: 172ms
memory: 13584kb

input:

1
3 1000
1 240
1 264
2 150
2 316
3 62
3 573
4 37
4 458
5 346
5 453
6 141
6 418
7 64
7 110
8 473
8 822
9 55
9 713
10 368
10 610
11 520
11 542
12 842
12 962
13 486
13 831
14 46
14 999
15 69
15 586
16 318
16 538
17 154
17 709
18 157
18 174
19 126
19 163
20 107
20 293
21 364
21 444
22 260
22 307
23 807
...

output:

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

input:

2
3 1000 718
1
1
1
0
0
0
1
1
0
1
1
0
0
1
0
0
1
0
1
0
1
1
0
0
1
1
0
0
0
0
0
1
1
1
0
0
1
0
1
1
0
1
1
1
1
0
1
0
0
1
0
1
1
1
1
0
1
0
1
1
1
1
1
1
0
1
1
0
0
1
1
0
1
0
1
1
1
0
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
1
1
0
1
1
1
0
0
0
1
1
1
1
1
0
1
0
0
1
0
0
1
1
1
0
1
1
1
1
0
1
0
0
0
0
1
1
1
0
1
1
1
1
0
1
0
0
1
1
0...

output:

2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 711
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 676
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 524
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 873
2 2 1
2 2 2
2 2 3
2 2 4
...

result:

ok OK

Test #9:

score: 19
Accepted
time: 248ms
memory: 13988kb

input:

1
3 1000
1 395
1 881
2 288
2 434
3 172
3 463
4 14
4 83
5 758
5 857
6 150
6 305
7 125
7 301
8 252
8 590
9 225
9 931
10 127
10 203
11 65
11 629
12 455
12 975
13 265
13 329
14 734
15 196
15 231
16 242
16 500
17 447
17 710
18 190
18 885
19 154
19 636
20 101
20 616
21 151
21 679
22 84
22 164
23 76
23 835...

output:

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

input:

2
3 1000 871
0
0
1
1
0
1
1
0
1
0
1
0
1
1
1
0
0
1
1
0
1
1
0
0
1
1
1
0
1
1
1
1
1
1
1
0
1
0
1
0
1
0
0
1
1
1
1
1
0
1
0
0
0
0
1
1
0
0
0
1
0
0
0
1
0
1
1
1
0
1
0
1
1
0
1
1
1
0
0
1
1
1
0
0
1
0
1
1
1
1
0
0
1
1
0
0
0
0
1
0
0
1
0
1
1
1
1
1
0
1
0
0
0
0
1
0
0
0
0
0
1
0
1
0
0
1
1
1
1
0
0
1
1
1
0
0
0
1
0
1
0
1
1
1...

output:

2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 364
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 718
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 988
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 171
2 2 1
2 2 2
2 2 3
2 2 4
...

result:

ok OK

Subtask #4:

score: 12
Accepted

Test #10:

score: 12
Accepted
time: 36ms
memory: 14896kb

input:

1
4 1000
1 103
1 881
2 195
2 740
3 224
4 558
5 749
5 788
6 189
7 221
8 362
9 267
9 547
10 205
10 813
10 926
11 23
12 687
13 225
14 366
14 768
15 58
15 156
15 869
16 79
16 225
17 61
17 437
18 500
18 534
18 768
18 989
19 300
20 909
21 970
22 245
22 425
23 528
23 669
23 809
23 890
24 121
24 778
25 845
...

output:

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

input:

2
4 1000 196
1
0
0
0
0
1
1
0
1
1
1
0
0
1
0
1
1
1
0
1
1
1
0
1
0
0
1
1
0
0
1
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
1
1
0
0
0
0
0
1
1
0
0
1
0
0
1
1
1
1
0
1
0
0
0
1
1
0
0
0
1
1
1
0
1
0
0
1
0
0
0
1
0
1
0
0
1
1
1
0
0
1
0
1
1
1
0
0
1
1
1
0
1
1
0
1
0
1
0
1
1
1
0
0
0
0
1
1
1
1
1
0
0
0
0
0
0
1
0
0
1
1
1
0
0
1
0
0
1
1...

output:

2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 865
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 884
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 306
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 345
2 2 1
2 2 2
2 2 3
2 2 4
...

result:

ok OK

Test #11:

score: 12
Accepted
time: 12ms
memory: 14080kb

input:

1
4 1000
1 324
1 458
1 592
2 187
2 495
2 811
3 11
4 847
5 660
6 579
7 504
8 364
8 474
8 825
9 81
9 755
9 827
10 707
11 680
11 934
12 245
13 937
14 509
14 716
14 783
15 179
15 684
15 856
16 208
16 232
16 260
17 810
17 862
17 892
18 241
19 140
19 496
19 545
20 206
20 339
20 717
21 716
22 664
22 723
22...

output:

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

input:

2
4 1000 321
0
0
0
1
0
1
1
0
0
1
1
1
0
0
0
0
0
1
0
0
1
1
1
1
0
1
1
1
0
1
1
1
1
1
1
1
0
1
1
1
0
0
0
1
1
1
0
1
1
0
0
1
0
1
1
1
1
1
0
0
1
1
0
1
1
1
0
1
1
0
0
0
0
1
1
0
1
0
0
0
1
0
0
1
0
0
0
1
0
1
0
1
0
0
1
1
1
0
1
1
0
0
0
0
0
0
0
0
0
1
0
0
1
0
0
0
1
0
1
0
1
0
1
0
1
0
0
1
1
1
0
1
1
0
0
0
0
1
0
1
0
0
1
1...

output:

2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 616
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 577
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 955
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 119
2 2 1
2 2 2
2 2 3
2 2 4
...

result:

ok OK

Test #12:

score: 12
Accepted
time: 25ms
memory: 15124kb

input:

1
4 1000
1 520
2 907
3 861
4 464
5 881
6 726
7 639
8 786
9 860
10 732
11 777
12 522
13 789
14 792
15 392
16 861
17 789
18 522
19 726
20 449
21 392
22 61
23 117
24 392
25 522
26 371
27 833
28 777
29 918
30 881
31 732
32 556
33 117
34 833
35 918
36 861
37 726
38 860
39 117
40 632
41 420
42 774
43 747
...

output:

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

input:

2
4 1000 984
1
1
0
0
0
0
0
0
0
1
1
1
0
1
1
1
1
0
0
1
1
1
0
0
0
1
0
0
0
0
0
1
1
1
0
0
0
0
0
0
0
0
0
1
0
0
0
1
0
0
0
0
0
1
1
0
1
0
0
1
1
0
0
0
0
1
0
1
1
1
0
1
1
1
0
1
0
0
0
1
1
1
1
0
1
0
1
1
0
0
0
1
1
1
1
1
1
0
0
0
1
0
0
1
1
0
0
1
0
1
0
0
1
0
0
1
1
1
0
1
0
1
0
0
1
0
0
1
1
1
1
1
0
1
0
0
1
0
0
1
1
0
0
1...

output:

2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 515
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 829
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 520
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 1
2 2 11
2 2 12
2 2 13
2 2 1...

result:

ok OK

Test #13:

score: 12
Accepted
time: 95ms
memory: 15204kb

input:

1
4 1000
1 975
1 981
2 398
2 808
3 673
4 673
5 673
6 334
6 543
7 673
8 673
9 673
10 448
10 707
11 252
11 486
12 673
13 335
13 943
14 624
14 663
15 673
16 673
17 673
18 673
19 673
20 673
21 132
21 877
22 673
23 673
24 673
25 348
25 536
26 673
27 673
28 588
28 845
29 563
29 860
30 716
30 906
31 673
32...

output:

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

input:

2
4 1000 136
1
1
0
0
1
0
0
1
1
0
1
1
0
0
0
0
1
0
1
0
0
1
1
1
1
0
0
0
0
0
1
0
1
1
1
0
0
1
1
1
0
1
1
1
0
0
1
0
0
1
0
0
0
1
1
0
0
0
1
1
0
0
0
0
1
1
1
0
0
1
1
0
0
0
0
0
1
0
0
1
1
1
0
1
0
1
0
1
0
0
0
0
1
1
1
1
1
0
1
0
0
0
0
1
1
0
0
0
1
1
1
1
1
0
1
0
0
0
1
0
1
0
1
0
1
1
0
1
1
1
0
1
1
1
1
1
0
0
0
0
0
1
1
1...

output:

2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 403
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 161
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 263
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 883
2 2 1
2 2 2
2 2 3
2 2 4
...

result:

ok OK

Test #14:

score: 12
Accepted
time: 12ms
memory: 14056kb

input:

1
4 1000
1 61
1 330
1 587
2 67
2 383
2 719
3 856
3 878
3 973
4 391
5 248
5 391
5 983
6 118
6 354
6 730
7 327
7 467
7 778
8 402
8 496
8 526
9 239
9 686
9 749
10 280
10 914
11 87
11 651
12 203
12 572
13 203
14 485
14 498
15 21
15 89
15 128
16 437
16 512
16 838
17 111
17 273
18 519
19 302
19 335
19 915...

output:

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

input:

2
4 1000 671
1
0
0
1
0
0
0
0
1
0
1
1
1
1
1
0
1
0
0
0
1
1
1
0
1
1
0
0
0
1
0
1
1
1
1
0
0
0
0
1
0
0
1
1
1
1
1
0
0
0
0
1
1
1
1
0
0
1
1
1
1
1
1
1
0
1
1
1
0
0
1
0
0
0
1
0
1
0
1
1
1
0
1
1
0
1
1
1
1
1
0
0
0
0
0
0
0
0
1
1
0
1
1
0
0
1
1
1
1
1
0
0
0
1
0
1
0
0
1
1
1
1
1
1
1
0
1
1
1
0
0
1
1
0
0
1
0
0
0
0
0
0
1
1...

output:

2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 265
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 559
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 653
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 579
2 2 1
2 2 2
2 2 3
2 2 4
...

result:

ok OK

Test #15:

score: 12
Accepted
time: 9ms
memory: 14108kb

input:

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

output:

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

input:

2
4 1000 820
1
0
0
0
0
0
0
0
0
0
1
0
0
1
0
1
1
0
0
1
1
1
0
1
0
0
0
0
0
0
0
0
1
0
1
1
1
1
0
0
0
0
0
0
0
0
1
1
0
0
1
0
0
0
0
0
0
0
1
1
1
0
1
0
0
0
0
0
0
0
1
1
0
1
1
0
0
0
0
0
0
0
1
1
1
1
1
0
0
0
0
0
0
0
1
1
0
0
0
1
0
0
0
0
0
0
1
1
1
0
0
1
0
0
0
0
0
0
1
1
0
1
0
1
0
0
0
0
0
0
1
1
1
1
0
1
0
0
0
0
0
0
1
1...

output:

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

result:

ok OK

Subtask #5:

score: 40
Accepted

Test #16:

score: 40
Accepted
time: 37ms
memory: 15380kb

input:

1
5 1000
1 296
1 974
2 414
3 777
4 158
4 918
5 535
5 799
5 952
6 290
7 17
7 420
8 223
9 600
10 743
11 189
11 239
11 530
11 619
12 27
12 451
13 580
14 165
15 552
15 753
16 883
16 936
17 292
17 398
17 904
18 355
18 678
19 807
20 577
21 392
21 744
22 600
23 582
23 717
23 915
24 70
24 254
24 492
25 115
...

output:

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

input:

2
5 1000 274
1
0
1
1
0
1
0
0
1
0
1
1
1
0
0
0
0
1
0
1
0
1
0
1
0
0
0
1
0
1
0
0
1
1
1
1
1
1
0
0
0
1
0
1
1
0
0
0
0
1
0
0
1
0
1
0
0
1
0
0
0
0
1
1
0
1
0
1
0
0
0
0
0
0
1
0
1
0
0
1
1
1
0
1
0
1
0
1
1
1
1
1
0
1
0
1
1
0
1
0
1
1
0
1
0
1
0
0
1
1
0
1
0
0
1
1
1
1
0
0
1
0
1
1
1
1
0
1
1
1
1
1
0
0
1
1
1
0
1
0
0
0
1
1...

output:

2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 301
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 323
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 162
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 287
2 2 1
2 2 2
2 2 3
2 2 4
...

result:

ok Partial solution

Test #17:

score: 40
Accepted
time: 18ms
memory: 14932kb

input:

1
5 1000
1 266
2 738
3 219
3 581
3 761
4 332
5 702
6 651
7 416
7 716
7 756
8 73
8 758
8 845
9 710
10 520
10 539
10 917
11 674
12 242
12 966
12 996
13 239
13 640
13 885
14 233
15 472
15 543
15 646
16 897
17 502
17 801
17 986
18 113
18 453
18 677
19 299
20 878
21 145
21 494
21 747
22 233
23 962
24 333...

output:

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

input:

2
5 1000 556
0
1
1
0
0
0
1
0
0
0
1
0
0
0
1
1
1
1
1
1
0
1
0
0
1
1
1
0
1
0
0
1
1
0
0
1
1
1
0
1
0
1
1
1
0
1
1
1
1
1
1
0
0
1
1
0
1
0
0
1
1
0
1
1
1
1
0
0
1
1
0
1
0
1
1
0
1
1
0
0
1
0
0
1
0
1
0
1
0
1
0
1
0
0
1
1
1
0
1
1
1
1
0
1
0
1
0
0
0
1
0
1
0
0
0
0
1
0
0
0
1
1
0
1
0
0
1
1
0
0
0
1
0
1
0
1
0
0
0
0
1
0
1
1...

output:

2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 70
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 504
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 604
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 860
2 2 1
2 2 2
2 2 3
2 2 4
2...

result:

ok Partial solution

Test #18:

score: 40
Accepted
time: 40ms
memory: 13956kb

input:

1
5 1000
1 76
2 320
3 514
4 607
5 20
6 900
7 320
8 363
9 436
10 107
11 424
12 176
13 357
14 895
15 268
16 268
17 607
18 514
19 320
20 51
20 55
20 57
20 140
20 148
20 177
20 254
20 347
20 364
20 370
20 390
20 459
20 461
20 487
20 533
20 599
20 659
20 677
20 710
20 714
20 769
20 775
20 893
20 894
20 9...

output:

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

input:

2
5 1000 505
1
0
0
0
0
1
1
0
0
1
1
1
1
1
0
0
1
1
1
1
0
1
0
0
1
1
0
0
1
0
0
0
1
1
0
0
0
0
0
0
0
0
0
1
0
0
1
1
0
0
1
0
0
0
1
1
1
1
1
1
0
0
0
0
0
1
0
1
1
0
1
1
0
0
0
1
0
0
0
1
1
0
0
0
1
0
0
1
0
0
0
1
1
1
1
0
0
1
1
0
1
0
0
1
1
0
0
1
0
1
1
0
1
0
0
1
1
1
0
0
1
1
1
0
1
0
0
1
1
1
1
0
0
1
0
1
1
0
0
1
1
1
0
0...

output:

2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 609
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 487
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 76
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 1
2 2 11
2 2 12
2 2 13
2 2 14...

result:

ok Partial solution

Test #19:

score: 40
Accepted
time: 37ms
memory: 14244kb

input:

1
5 1000
1 315
1 893
2 468
3 468
4 468
5 419
5 619
6 468
7 139
7 827
8 42
8 658
9 650
9 930
10 468
11 468
12 157
12 263
13 468
14 468
15 845
15 923
16 468
17 468
18 71
18 964
19 468
20 468
21 468
22 458
22 790
23 468
24 468
25 88
25 890
26 468
27 468
28 195
28 636
29 559
29 912
30 715
30 752
31 468
...

output:

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

input:

2
5 1000 1000
0
0
1
0
1
0
1
1
1
0
1
1
0
0
1
0
0
0
0
1
0
1
1
0
1
1
0
0
1
0
1
0
1
0
0
0
1
0
1
1
1
1
0
1
0
1
1
1
0
0
1
0
1
0
1
0
0
0
1
0
1
1
1
0
0
1
0
1
0
1
1
0
1
1
0
1
1
0
1
1
0
0
0
0
0
1
1
1
0
1
1
1
0
1
1
0
1
1
1
1
1
0
1
0
1
1
1
0
1
1
0
0
0
0
1
0
1
0
0
0
1
1
0
0
0
1
1
0
1
0
1
1
0
0
1
0
0
1
0
1
1
0
1
...

output:

2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 468
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 265
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 333
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 488
2 2 1
2 2 2
2 2 3
2 2 4
...

result:

ok Partial solution

Test #20:

score: 40
Accepted
time: 9ms
memory: 14880kb

input:

1
5 1000
1 565
2 6
2 659
3 370
4 133
5 114
5 780
6 18
6 38
6 49
6 83
6 85
6 112
6 131
6 167
6 279
6 296
6 330
6 343
6 356
6 370
6 385
6 415
6 447
6 450
6 532
6 589
6 614
6 668
6 698
6 724
6 752
6 761
6 767
6 782
6 867
6 872
6 929
6 954
6 957
6 992
7 52
7 534
8 27
9 27
10 906
11 475
12 89
13 214
14 3...

output:

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

input:

2
5 1000 534
0
0
0
1
0
0
0
1
1
1
1
0
0
0
0
1
1
1
1
0
1
1
1
0
1
0
1
1
0
0
0
1
1
1
0
0
0
0
0
0
0
0
0
1
1
0
1
0
1
1
0
0
0
1
1
1
1
0
0
0
1
0
0
0
0
1
0
1
1
0
0
0
0
1
1
0
0
0
0
1
1
1
1
0
1
1
0
1
0
0
0
1
1
1
1
1
1
1
0
1
0
0
0
1
1
0
0
1
1
0
0
0
1
0
0
1
1
1
0
1
1
1
0
0
1
0
0
1
1
0
0
0
0
0
0
1
1
0
0
1
1
0
0
1...

output:

2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 904
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 752
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 565
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 1
2 2 11
2 2 12
2 2 13
2 2 1...

result:

ok Partial solution

Test #21:

score: 40
Accepted
time: 17ms
memory: 14024kb

input:

1
5 1000
1 205
2 13
2 261
2 376
3 194
3 437
3 545
4 718
4 922
5 414
5 507
5 921
6 190
7 863
8 339
8 557
9 66
9 955
10 92
10 462
10 512
11 167
11 662
11 926
12 690
12 801
13 314
13 757
14 363
14 592
15 237
15 280
15 572
16 747
16 930
17 686
17 699
18 362
18 815
18 980
18 990
19 148
19 538
20 419
20 7...

output:

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

input:

2
5 1000 39
0
1
1
0
0
1
1
1
1
0
1
1
1
0
1
1
1
1
0
1
1
1
0
0
0
0
0
1
1
0
1
1
1
1
1
1
1
1
0
1
1
0
0
1
1
1
1
0
0
0
1
0
0
0
1
0
0
0
1
1
0
1
1
1
1
1
0
0
0
1
0
1
1
1
1
0
1
1
1
1
0
1
1
1
1
0
1
1
0
1
1
0
0
1
1
0
0
0
1
1
0
0
1
0
0
1
0
1
0
1
1
1
1
0
1
0
1
1
0
0
1
0
1
1
1
0
1
1
0
0
1
1
1
0
0
0
1
0
0
0
1
1
1
0
...

output:

2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 486
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 891
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 864
2 2 1
2 2 2
2 2 3
2 2 4
2 2 5
2 2 6
2 2 7
2 2 8
2 2 9
2 2 10
2 3 223
2 2 1
2 2 2
2 2 3
2 2 4
...

result:

ok Partial solution

Test #22:

score: 40
Accepted
time: 18ms
memory: 15064kb

input:

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

output:

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

input:

2
5 1000 537
1
0
0
0
0
0
0
0
0
0
1
1
0
0
1
1
0
0
0
0
1
1
0
1
0
0
0
0
0
0
0
0
1
0
1
1
1
1
0
0
0
0
0
0
0
0
1
1
0
0
1
0
0
0
0
0
0
0
1
1
1
0
1
0
0
0
0
0
0
0
1
1
0
1
1
0
0
0
0
0
0
0
1
1
1
1
1
0
0
0
0
0
0
0
1
1
0
0
0
1
0
0
0
0
0
0
1
1
1
0
0
1
0
0
0
0
0
0
1
1
0
1
0
1
0
0
0
0
0
0
1
1
1
1
0
1
0
0
0
0
0
0
1
1...

output:

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

result:

ok Partial solution