QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#177150#6396. Puzzle: Kusabiucup-team1547#AC ✓26ms25288kbC++142.8kb2023-09-12 16:32:582023-09-12 16:32:58

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

8
2 1 -
3 1 -
4 2 Tong
5 2 Tong
6 3 Duan
7 3 -
8 7 Chang

output:

YES
6 8
4 5

result:

ok Correct.

Test #2:

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

input:

10
2 1 Duan
3 2 Duan
4 2 -
5 4 Chang
6 2 Chang
7 1 Duan
8 6 Tong
9 6 Tong
10 3 Chang

output:

YES
8 9
3 10
2 6
7 5

result:

ok Correct.

Test #3:

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

input:

2
2 1 Tong

output:

NO

result:

ok Correct.

Test #4:

score: 0
Accepted
time: 21ms
memory: 14176kb

input:

100000
2 1 Duan
3 1 Duan
4 3 -
5 4 Duan
6 3 -
7 4 Duan
8 4 -
9 8 -
10 7 Duan
11 9 -
12 7 Duan
13 7 Duan
14 8 Duan
15 13 -
16 10 Duan
17 11 Duan
18 12 -
19 1 Duan
20 5 Duan
21 4 Duan
22 14 Duan
23 16 -
24 22 Duan
25 16 Duan
26 13 -
27 13 -
28 17 -
29 5 Duan
30 22 -
31 23 -
32 9 Duan
33 5 -
34 30 Duan...

output:

YES
61327 78961
28763 79617
25684 40169
25045 49361
24156 60228
50185 97603
56901 72206
10579 41848
73900 76635
50152 73042
25325 47346
63312 91464
79886 91034
27084 53651
10551 20428
36927 98200
69283 80157
68167 78977
10332 33135
40003 87866
10300 10826
81993 83126
63025 61240
32742 51469
26924 33...

result:

ok Correct.

Test #5:

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

input:

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

output:

YES
54260 61365
66883 94528
52379 80746
25539 57632
70587 86270
10692 50931
46038 46315
3973 51215
40468 42355
28057 31649
73329 57657
26291 66814
21998 29098
45470 93763
54966 84353
41071 74078
25774 30942
59287 51936
9388 82007
8527 40293
57690 97856
67337 76507
76115 58992
90319 76631
51620 86905...

result:

ok Correct.

Test #6:

score: 0
Accepted
time: 22ms
memory: 14984kb

input:

100000
2 1 -
3 2 -
4 3 Duan
5 4 Chang
6 5 Duan
7 6 Chang
8 7 Duan
9 8 Chang
10 9 Duan
11 10 Chang
12 11 Duan
13 12 Chang
14 12 Duan
15 14 Chang
16 15 Tong
17 15 Tong
18 17 Duan
19 18 Duan
20 19 Chang
21 18 Duan
22 21 Duan
23 18 Chang
24 21 -
25 24 Duan
26 25 Chang
27 26 Duan
28 27 Chang
29 26 Duan
3...

output:

YES
31 37
40 42
64 68
173 203
150 196
771 820
744 777
803 809
799 810
552 778
528 556
374 446
345 423
772 920
570 708
510 524
649 682
588 610
660 652
397 587
396 433
291 503
641 686
549 645
529 536
429 478
321 348
286 294
284 323
282 316
279 307
341 376
501 530
1152 1160
1446 1757
1435 1685
1413 142...

result:

ok Correct.

Test #7:

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

input:

100000
2 1 -
3 2 -
4 3 -
5 4 -
6 5 -
7 6 -
8 7 -
9 8 -
10 9 Duan
11 10 -
12 11 Chang
13 12 Duan
14 13 Chang
15 14 -
16 15 -
17 16 Duan
18 17 Chang
19 17 -
20 19 -
21 20 -
22 21 -
23 22 -
24 23 -
25 24 -
26 25 Duan
27 26 -
28 27 Duan
29 28 -
30 29 Chang
31 28 -
32 31 Chang
33 32 -
34 32 -
35 34 -
36 ...

output:

YES
126 131
174 185
197 216
173 189
163 181
151 160
138 144
169 199
207 218
223 255
287 290
260 262
291 359
489 545
362 372
320 468
306 315
279 286
244 247
603 660
758 809
784 902
708 762
751 786
746 779
663 775
756 763
658 716
589 675
648 686
566 591
582 613
621 655
643 711
562 579
560 628
577 690
...

result:

ok Correct.

Test #8:

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

input:

100000
2 1 -
3 2 -
4 3 -
5 4 -
6 5 Duan
7 6 -
8 7 -
9 8 -
10 9 Chang
11 10 -
12 11 Duan
13 12 Chang
14 13 -
15 14 Duan
16 15 Chang
17 16 -
18 17 -
19 18 Duan
20 19 -
21 20 -
22 21 -
23 22 Chang
24 23 -
25 24 Duan
26 25 -
27 26 Chang
28 27 -
29 28 -
30 29 -
31 30 Duan
32 31 -
33 32 -
34 33 -
35 34 -
...

output:

YES
155 161
249 251
277 292
424 430
368 381
353 383
380 386
422 429
490 493
528 532
526 545
534 551
531 540
555 556
661 665
641 642
639 650
638 646
622 624
621 625
612 614
627 630
615 629
598 609
700 706
718 725
786 820
873 875
835 852
903 909
857 865
850 866
802 813
801 810
770 772
696 698
694 780
...

result:

ok Correct.

Test #9:

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

input:

100000
2 1 -
3 2 -
4 3 -
5 4 -
6 5 Duan
7 6 -
8 7 -
9 8 Chang
10 9 -
11 10 Duan
12 11 -
13 12 Chang
14 13 Duan
15 14 -
16 15 Chang
17 16 -
18 17 Duan
19 18 -
20 19 Chang
21 20 Duan
22 21 Chang
23 22 -
24 23 Duan
25 24 Chang
26 25 Duan
27 26 -
28 27 -
29 28 Chang
30 29 Duan
31 30 Chang
32 31 -
33 32 ...

output:

YES
306 308
356 357
450 453
554 556
549 552
547 548
568 570
567 569
676 682
671 672
737 738
728 735
801 805
794 806
791 793
908 910
914 922
946 952
991 1004
1011 1016
1014 1024
1156 1164
1153 1160
1151 1155
1140 1147
1097 1102
1094 1095
1089 1093
1075 1076
1122 1123
1125 1129
1134 1135
1154 1157
114...

result:

ok Correct.

Test #10:

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

input:

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

output:

YES
4758 4774
11802 12004
12701 12878
14425 14403
15095 15175
16218 16272
15803 15813
15960 16111
17698 17703
18616 18828
20479 20553
22709 22767
24981 25371
23807 24571
23319 23781
28570 28616
26536 27425
29047 29756
29822 30157
29383 29413
35528 35551
34775 34909
33210 34774
33062 33101
39240 3988...

result:

ok Correct.

Test #11:

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

input:

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

output:

YES
68260 71252
72829 93199
11262 59385
7114 56366
21981 56413
88219 85882
70420 69070
46636 70961
24045 70919
8534 53558
6776 51312
14730 47483
8121 66745
14466 42970
3305 66071
37873 86329
12867 85723
31531 39119
56430 82602
34098 87213
40456 67836
24828 99956
17961 87387
68937 87569
73357 91017
1...

result:

ok Correct.

Test #12:

score: 0
Accepted
time: 9ms
memory: 11600kb

input:

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

output:

YES
67589 89903
2731 25532
39272 68594
15090 81476
60781 71809
98218 45615
9592 13863
38360 41771
32307 67278
46144 98634
36895 70045
56597 90229
21515 87249
7445 44881
70645 99328
51367 70229
15488 44757
38942 68314
361 31755
53849 62803
72268 74966
38644 42791
69049 39590
31128 60607
24390 68719
2...

result:

ok Correct.

Test #13:

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

input:

100000
2 1 Duan
3 1 Duan
4 1 Duan
5 1 Duan
6 1 Duan
7 1 -
8 1 Duan
9 1 Duan
10 1 -
11 1 Duan
12 1 -
13 1 Duan
14 1 Duan
15 1 Duan
16 1 Duan
17 1 Duan
18 2 -
19 1 Duan
20 1 Duan
21 2 -
22 2 Duan
23 1 Duan
24 1 Duan
25 1 Duan
26 1 Duan
27 2 Duan
28 1 Duan
29 2 Duan
30 1 Duan
31 2 Duan
32 1 -
33 1 Duan...

output:

YES
14629 99565
8043 58177
8022 77249
7886 99568
7106 97191
6452 79782
6438 98265
52710 73953
6320 76068
5888 84889
5812 81286
41217 65693
5668 97669
5312 65081
71711 74586
77289 92388
5206 89733
4798 79262
4777 99789
38566 72776
79617 84855
4736 67208
91965 96692
4470 58017
82143 93682
98993 99395
...

result:

ok Correct.

Test #14:

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

input:

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

output:

YES
3382 85599
3013 95392
79392 81526
76883 90600
2266 47562
67095 92236
2087 82645
83119 83294
86680 94655
53700 98104
1891 59880
84824 94429
1867 38939
72196 86276
1851 74866
1832 73841
33013 52187
75982 82555
60149 84502
77895 89910
90018 94488
1798 87531
1780 62543
45755 50707
63884 96747
67922 ...

result:

ok Correct.

Test #15:

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

input:

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

output:

YES
1484 93600
1226 65492
54647 80577
87425 98136
1057 92548
90647 95875
88522 91502
864 65449
63757 78454
863 57780
79380 91133
859 90975
77801 81087
69230 93397
847 63165
841 88299
61658 83594
91139 96200
67080 81529
96324 96779
74882 99215
99183 99293
56495 87893
778 78381
44807 81594
767 82056
7...

result:

ok Correct.

Test #16:

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

input:

100000
2 1 Duan
3 1 Duan
4 1 -
5 1 Duan
6 1 -
7 1 Duan
8 1 Duan
9 1 Duan
10 1 Duan
11 1 -
12 1 -
13 1 -
14 1 Duan
15 1 Duan
16 1 Duan
17 1 -
18 1 Duan
19 1 Duan
20 1 Duan
21 1 -
22 1 -
23 1 Duan
24 1 Duan
25 1 Duan
26 1 -
27 1 -
28 1 Duan
29 1 Duan
30 1 -
31 1 Duan
32 1 Duan
33 1 -
34 1 Duan
35 1 -
...

output:

YES
705 83464
622 95111
575 99954
91152 92518
93861 99688
531 92449
528 71582
524 66385
518 91774
95679 96388
502 95051
495 68161
491 92051
71560 79514
486 91617
466 92920
456 94768
69375 71375
82066 86414
455 94412
451 96222
86461 92101
97252 99900
437 86105
436 78526
65746 90094
82699 93000
430 84...

result:

ok Correct.

Test #17:

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

input:

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

output:

NO

result:

ok Correct.

Test #18:

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

input:

100000
2 1 Duan
3 2 Duan
4 3 -
5 3 Duan
6 4 -
7 4 Duan
8 3 Duan
9 2 -
10 4 Duan
11 8 Duan
12 6 -
13 3 Duan
14 6 Duan
15 7 Duan
16 6 Duan
17 14 Tong
18 7 -
19 16 Duan
20 14 Duan
21 12 Duan
22 20 Duan
23 14 Duan
24 19 -
25 2 Duan
26 22 -
27 24 Duan
28 8 Duan
29 4 Duan
30 23 Duan
31 24 Duan
32 23 Duan
...

output:

NO

result:

ok Correct.

Test #19:

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

input:

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

output:

NO

result:

ok Correct.

Test #20:

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

input:

100000
2 1 Duan
3 2 Chang
4 3 -
5 4 -
6 5 -
7 6 Duan
8 7 -
9 8 Chang
10 9 Duan
11 10 Chang
12 11 -
13 12 Duan
14 13 Chang
15 13 -
16 15 -
17 15 -
18 15 Duan
19 18 -
20 19 Duan
21 19 Chang
22 20 -
23 22 -
24 21 Duan
25 23 -
26 22 -
27 25 Chang
28 26 -
29 28 Duan
30 24 Chang
31 28 -
32 23 -
33 28 -
34...

output:

NO

result:

ok Correct.

Test #21:

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

input:

100000
2 1 Duan
3 2 Chang
4 3 -
5 4 -
6 5 Duan
7 6 -
8 7 -
9 8 Chang
10 9 Duan
11 10 Chang
12 11 Duan
13 12 Chang
14 12 -
15 14 -
16 15 Duan
17 16 Chang
18 17 -
19 17 Duan
20 19 -
21 19 Chang
22 21 -
23 21 Duan
24 23 Duan
25 24 Chang
26 24 Chang
27 24 Duan
28 27 -
29 28 Chang
30 28 Duan
31 30 -
32 3...

output:

NO

result:

ok Correct.

Test #22:

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

input:

100000
2 1 Duan
3 2 Chang
4 3 Duan
5 4 -
6 5 Chang
7 6 -
8 7 Duan
9 8 -
10 9 Chang
11 10 Duan
12 11 Chang
13 12 -
14 13 Duan
15 14 -
16 15 Chang
17 16 -
18 17 Duan
19 18 -
20 19 -
21 20 -
22 21 Chang
23 22 -
24 23 Duan
25 24 Chang
26 25 -
27 26 Duan
28 27 -
29 28 Chang
30 28 Duan
31 30 -
32 31 Chang...

output:

NO

result:

ok Correct.

Test #23:

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

input:

100000
2 1 Duan
3 2 -
4 3 -
5 4 -
6 5 -
7 6 -
8 7 -
9 8 -
10 9 -
11 10 -
12 11 Chang
13 12 Duan
14 13 -
15 14 -
16 15 Chang
17 16 Duan
18 17 Chang
19 18 -
20 19 -
21 20 -
22 21 -
23 22 -
24 23 -
25 24 -
26 25 Duan
27 26 -
28 27 -
29 28 -
30 29 -
31 30 -
32 31 -
33 32 -
34 33 Chang
35 34 -
36 35 -
37...

output:

NO

result:

ok Correct.

Test #24:

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

input:

100000
2 1 -
3 2 -
4 3 -
5 4 -
6 5 Duan
7 6 -
8 7 Chang
9 8 -
10 9 -
11 10 -
12 11 -
13 12 -
14 13 Duan
15 14 -
16 15 Chang
17 16 -
18 17 -
19 18 -
20 19 Duan
21 20 -
22 21 -
23 22 -
24 23 Chang
25 24 -
26 25 Duan
27 26 Chang
28 27 Duan
29 28 -
30 29 -
31 30 -
32 31 Chang
33 32 Duan
34 33 -
35 34 -
...

output:

NO

result:

ok Correct.

Test #25:

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

input:

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

output:

NO

result:

ok Correct.

Test #26:

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

input:

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

output:

NO

result:

ok Correct.

Test #27:

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

input:

100000
2 1 Duan
3 1 Duan
4 1 Duan
5 1 Duan
6 1 Duan
7 1 Duan
8 1 Duan
9 1 Duan
10 1 Duan
11 1 Duan
12 1 Duan
13 1 Duan
14 2 Duan
15 1 Duan
16 1 Duan
17 1 Duan
18 2 Duan
19 1 Duan
20 1 -
21 1 Duan
22 1 Duan
23 1 Duan
24 1 Duan
25 1 Duan
26 1 Duan
27 2 Duan
28 1 Duan
29 1 Duan
30 1 -
31 1 Duan
32 1 Du...

output:

NO

result:

ok Correct.

Test #28:

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

input:

100000
2 1 -
3 1 Duan
4 1 -
5 1 -
6 1 -
7 1 Duan
8 1 -
9 1 Duan
10 1 -
11 1 Duan
12 1 Duan
13 1 Duan
14 1 Duan
15 1 Duan
16 1 -
17 1 Duan
18 1 Duan
19 1 Duan
20 1 Duan
21 1 -
22 1 -
23 1 Duan
24 1 -
25 1 Duan
26 1 Duan
27 1 Duan
28 1 Duan
29 1 Duan
30 1 Duan
31 1 Duan
32 1 -
33 1 -
34 1 Duan
35 1 Du...

output:

NO

result:

ok Correct.

Test #29:

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

input:

100000
2 1 Duan
3 1 Duan
4 1 Duan
5 1 Duan
6 1 Duan
7 1 Duan
8 1 -
9 1 Duan
10 1 Duan
11 1 Duan
12 1 -
13 1 Duan
14 1 Duan
15 1 Duan
16 1 Duan
17 1 Duan
18 1 Duan
19 1 Duan
20 1 -
21 1 -
22 1 Duan
23 1 -
24 1 Duan
25 1 Duan
26 1 Duan
27 1 Duan
28 1 Duan
29 1 Duan
30 1 Duan
31 1 Duan
32 1 Duan
33 1 -...

output:

NO

result:

ok Correct.

Test #30:

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

input:

100000
2 1 Duan
3 1 -
4 1 Duan
5 1 Duan
6 1 Duan
7 1 Duan
8 1 Duan
9 1 Duan
10 1 Duan
11 1 Duan
12 1 Duan
13 1 Duan
14 1 Duan
15 1 Duan
16 1 Duan
17 1 Duan
18 1 Duan
19 1 -
20 1 Duan
21 1 Duan
22 1 Duan
23 1 Duan
24 1 Duan
25 1 Duan
26 1 Duan
27 1 Duan
28 1 -
29 1 Duan
30 1 Duan
31 1 Duan
32 1 -
33 ...

output:

NO

result:

ok Correct.

Test #31:

score: 0
Accepted
time: 21ms
memory: 25288kb

input:

100000
2 1 Duan
3 2 -
4 3 Chang
5 4 -
6 5 Duan
7 6 Chang
8 7 -
9 8 -
10 9 Duan
11 10 Chang
12 11 Duan
13 12 Chang
14 13 Duan
15 14 Chang
16 15 -
17 16 -
18 17 -
19 18 Duan
20 19 -
21 20 -
22 21 Chang
23 22 Duan
24 23 Chang
25 24 -
26 25 Duan
27 26 Chang
28 27 Duan
29 28 -
30 29 Chang
31 30 Duan
32 3...

output:

YES
38668 38669
43573 43574
44575 44576
44896 44897
47954 47955
48086 48087
51731 51732
52698 52699
53051 53053
53843 53844
54079 54080
55169 55170
56247 56248
56590 56591
57028 57029
57089 57090
57208 57209
57205 57206
57691 57692
57806 57809
58261 58262
58318 58319
59076 59077
59130 59134
59427 59...

result:

ok Correct.

Test #32:

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

input:

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

output:

YES
90226 92627
80552 98157
66335 67953
85511 86134
86460 86996
89512 89806
92271 94233
96463 99736
48609 55714
56615 60624
64372 65770
69427 71357
72862 73888
73891 74512
77025 79593
80845 81710
81856 82075
82419 83893
85318 85374
85698 87691
88314 89327
89757 91747
92085 92584
93512 95440
97391 99...

result:

ok Correct.

Test #33:

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

input:

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

output:

YES
20816 74513
66130 81879
35338 89777
62475 73761
37702 71335
23517 33453
15222 56223
86688 91225
7805 29499
86109 58463
24560 41026
5910 47941
15686 44357
20522 70706
9149 22815
46379 66681
71082 81135
24083 47858
46291 85674
75184 79873
87023 73465
33095 41087
9719 56514
3487 53207
58715 82993
4...

result:

ok Correct.

Test #34:

score: 0
Accepted
time: 25ms
memory: 14216kb

input:

92284
2 1 Duan
3 2 -
4 3 Duan
5 2 Duan
6 3 -
7 4 Duan
8 6 Duan
9 4 Duan
10 6 Duan
11 4 Duan
12 8 Chang
13 1 Duan
14 5 Duan
15 5 -
16 15 Duan
17 15 Duan
18 13 Chang
19 12 Duan
20 4 -
21 1 Duan
22 17 Duan
23 2 Duan
24 14 Duan
25 17 Duan
26 22 Duan
27 4 -
28 26 Duan
29 9 Duan
30 15 Duan
31 3 Duan
32 7 ...

output:

YES
59373 72399
59795 64277
62511 76031
48883 62495
39444 59778
16425 86492
13682 49780
46706 65245
46022 57764
12085 12089
12688 91021
41203 66749
17794 40403
62095 90300
58704 62751
19440 22903
35611 40542
71273 77274
27633 72403
27548 47603
44368 44456
16807 41743
12412 24344
41680 61518
52077 61...

result:

ok Correct.

Test #35:

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

input:

93444
2 1 -
3 1 Duan
4 1 Duan
5 2 -
6 4 -
7 3 -
8 6 Duan
9 6 Duan
10 9 -
11 2 -
12 1 -
13 11 -
14 5 -
15 14 Duan
16 11 -
17 16 -
18 4 -
19 7 Duan
20 15 -
21 17 -
22 21 -
23 20 -
24 23 Duan
25 7 -
26 14 Duan
27 18 -
28 13 Duan
29 2 Duan
30 19 Duan
31 5 -
32 7 Duan
33 23 Duan
34 17 Duan
35 2 Duan
36 2...

output:

YES
18291 80381
42330 58464
59400 65585
1955 28016
40901 74817
89642 53918
4623 63353
82334 84984
57215 61350
54608 68628
6183 89498
50593 51738
36029 59238
62682 78448
8962 76817
53894 77371
25512 32196
36051 72379
15907 61507
17172 57517
14874 24983
79759 45334
4252 7489
58719 61241
40373 47115
29...

result:

ok Correct.

Test #36:

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

input:

98244
2 1 Duan
3 1 Duan
4 3 Duan
5 4 Duan
6 4 Duan
7 4 Duan
8 5 Duan
9 8 Duan
10 5 Duan
11 9 Duan
12 3 Duan
13 11 Tong
14 5 Duan
15 5 Duan
16 12 Duan
17 2 Duan
18 3 Duan
19 4 Duan
20 2 Duan
21 6 Duan
22 21 Duan
23 1 -
24 15 -
25 20 Duan
26 8 Duan
27 13 Duan
28 12 Duan
29 22 Duan
30 24 Duan
31 21 Dua...

output:

YES
31567 39340
13251 95866
63302 95270
54023 92175
48934 93485
24639 59312
21809 26380
39929 59491
50304 93197
37132 74962
32873 50798
3734 89682
68142 10918
61493 77790
2062 13569
44405 89860
3203 61508
52369 69831
43739 49035
28930 38807
66372 75766
39400 86527
3875 26746
27472 15465
1690 26723
7...

result:

ok Correct.

Test #37:

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

input:

25284
2 1 Duan
3 2 -
4 3 -
5 3 Duan
6 2 Duan
7 3 Duan
8 1 Duan
9 5 -
10 4 -
11 5 Duan
12 4 Duan
13 1 Duan
14 4 -
15 10 Duan
16 8 -
17 13 -
18 15 -
19 12 -
20 16 Duan
21 6 Duan
22 2 Duan
23 19 -
24 12 -
25 2 -
26 19 Duan
27 5 -
28 4 -
29 9 -
30 12 Duan
31 7 Duan
32 31 -
33 21 -
34 24 Duan
35 28 Duan
...

output:

YES
14626 21135
13835 14096
4428 23638
14105 14395
8988 14359
18822 12572
1866 20771
15210 24821
7235 23534
1084 16843
18384 22081
9125 23584
7918 17968
16796 24718
8913 23519
3762 23223
1868 17039
7940 15456
2957 6852
14498 16581
9470 19923
17156 9699
1916 18582
1797 6193
8613 13962
3543 18684
737 ...

result:

ok Correct.

Test #38:

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

input:

93246
2 1 Duan
3 2 Duan
4 3 Duan
5 1 -
6 4 Tong
7 4 Duan
8 4 Duan
9 8 -
10 6 Duan
11 2 Duan
12 1 Duan
13 11 Duan
14 8 Duan
15 1 Duan
16 8 Duan
17 10 Duan
18 3 Duan
19 1 Duan
20 18 Duan
21 10 Duan
22 14 Duan
23 11 Duan
24 19 Duan
25 21 Duan
26 17 Duan
27 24 Duan
28 24 Duan
29 17 Tong
30 23 Duan
31 17...

output:

YES
81889 89030
44827 92357
18804 92091
71114 88411
19189 41235
26335 88624
34183 92987
13889 37071
5382 7117
9021 63386
26290 70522
44641 74182
36015 63647
90356 91664
48141 62270
32796 68439
29179 71774
76068 92998
27623 62275
19705 86091
11009 89771
4652 8510
3815 64403
9990 40253
1699 62617
4358...

result:

ok Correct.

Test #39:

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

input:

99837
2 1 -
3 1 -
4 3 Duan
5 2 Duan
6 5 Duan
7 3 Duan
8 5 -
9 6 Duan
10 4 -
11 4 -
12 6 Duan
13 8 -
14 7 -
15 10 Duan
16 11 Duan
17 8 Duan
18 6 -
19 13 Duan
20 16 Duan
21 20 -
22 19 Chang
23 4 Duan
24 13 Duan
25 21 -
26 17 Duan
27 7 Duan
28 8 -
29 3 -
30 18 -
31 21 Duan
32 27 Duan
33 21 Duan
34 17 -...

output:

YES
10410 92676
39274 64479
78859 94138
21274 30205
8785 30056
83693 37886
73635 88306
11691 28522
30919 57401
38138 64681
9496 93491
51332 63118
28452 66215
51297 92328
23727 94426
74562 77931
34253 42129
23327 48303
51081 79346
10299 74255
69759 78121
16245 96354
84360 90972
95214 62165
10872 1788...

result:

ok Correct.

Test #40:

score: 0
Accepted
time: 22ms
memory: 14612kb

input:

91248
2 1 Duan
3 1 Duan
4 1 Duan
5 2 Duan
6 3 Duan
7 3 Chang
8 2 Duan
9 1 Duan
10 7 Duan
11 10 Duan
12 4 Duan
13 2 Duan
14 11 Duan
15 6 Duan
16 8 Duan
17 7 Duan
18 2 Duan
19 15 Duan
20 4 Duan
21 7 Duan
22 6 Duan
23 6 Duan
24 20 Duan
25 13 Duan
26 22 Duan
27 5 Duan
28 19 Duan
29 14 Duan
30 12 -
31 8 ...

output:

YES
84342 88470
76377 84352
45791 63352
50883 88200
18535 44680
31347 47797
12022 50617
6719 66762
5130 67174
77457 89212
59725 66802
46630 69332
56151 90420
44293 80259
50828 74573
46329 68733
19496 53256
15888 32591
6154 48424
25680 27747
25066 81109
5287 89180
10884 54094
31562 32892
2581 2675
40...

result:

ok Correct.

Test #41:

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

input:

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

output:

YES
71885 78212
6100 37718
40991 49527
80389 92012
68659 81271
43095 62371
41814 79642
57857 73661
24540 48483
16398 52557
41232 56423
78939 54473
3709 48165
74318 74690
61871 68804
24101 24274
64890 70628
41770 84790
40451 53698
39635 42520
25034 91102
39256 90535
11894 91112
90078 77572
16393 7240...

result:

ok Correct.

Test #42:

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

input:

92384
2 1 Duan
3 2 -
4 3 Duan
5 3 Duan
6 3 -
7 2 Duan
8 1 -
9 7 Duan
10 5 Chang
11 4 -
12 3 Duan
13 7 -
14 9 Duan
15 14 Chang
16 3 Duan
17 6 Duan
18 10 Duan
19 17 Duan
20 10 -
21 2 Duan
22 10 -
23 5 Duan
24 18 -
25 11 -
26 13 Duan
27 12 Duan
28 1 -
29 18 Duan
30 28 Duan
31 28 -
32 16 -
33 27 Duan
34...

output:

YES
52483 65469
39644 66814
11062 44726
9868 79880
37247 59560
77144 88171
24217 76272
61782 85792
57105 80279
37735 68289
31363 58829
26773 44877
18959 91292
43740 70419
7777 15239
9911 90532
7970 31792
63278 48350
12673 57214
33091 78633
72507 87915
37461 71152
52979 55042
64528 72909
41920 44823
...

result:

ok Correct.

Test #43:

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

input:

1

output:

YES

result:

ok Correct.