QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#386199#6396. Puzzle: KusabiHuangHanShengAC ✓59ms70068kbC++204.6kb2024-04-11 13:57:362024-04-11 13:57:38

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 4ms
memory: 48244kb

input:

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

output:

YES
4 5
6 8

result:

ok Correct.

Test #2:

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

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
3 10
8 9
2 6
7 5

result:

ok Correct.

Test #3:

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

input:

2
2 1 Tong

output:

NO

result:

ok Correct.

Test #4:

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

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
68238 77477
55487 92481
80321 90768
26757 61425
93032 85218
61332 79084
38376 81194
84503 96568
80329 87650
80462 90175
56280 91879
80940 85183
45401 92379
47304 51481
37299 48856
55343 68883
15089 86813
61306 65869
20320 55002
68591 69982
74064 85031
61051 73448
29361 45787
42921 55495
82725 95...

result:

ok Correct.

Test #5:

score: 0
Accepted
time: 35ms
memory: 57468kb

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
77529 85007
80143 91387
85287 94990
57819 89837
41068 74899
70043 70086
37273 49983
65251 76734
34335 87688
94573 46653
92239 86640
36497 88248
77530 82691
36957 61348
87863 88167
86273 85912
33907 32074
70825 71093
37315 57414
56018 90566
61875 98528
78637 85275
60916 83397
39881 86820
74013 99...

result:

ok Correct.

Test #6:

score: 0
Accepted
time: 54ms
memory: 60568kb

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
97601 97840
98570 99292
99872 99923
93657 98674
97278 99927
96917 97153
89534 91919
90904 97037
91562 93849
88445 99416
88743 93859
97734 98027
95886 95961
98352 99213
98918 99109
97464 98937
82392 87179
93746 98530
90982 93238
94748 97229
88190 98532
87701 97134
86074 92178
88169 96151
81834 86...

result:

ok Correct.

Test #7:

score: 0
Accepted
time: 46ms
memory: 57300kb

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
91954 92861
91434 93335
98059 93899
92444 97461
94537 95439
92799 94126
87516 89614
93526 97921
88597 92766
87784 98040
88134 94698
95134 96777
91610 99421
87396 89001
85711 86295
89825 93157
92889 97958
83443 90842
84005 84896
85808 91724
98810 95932
89502 99875
87098 87268
86158 91531
95750 96...

result:

ok Correct.

Test #8:

score: 0
Accepted
time: 46ms
memory: 58316kb

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
97710 99449
98203 98482
99169 99472
99187 99881
99695 99926
99372 99486
96519 96571
94328 94569
99179 99882
99495 99924
94118 94920
97267 97800
97034 98388
95628 98506
98256 99032
99105 99734
97831 98060
94210 95502
96199 98303
98563 99149
99312 99392
99191 99511
98119 98548
98644 98661
98226 98...

result:

ok Correct.

Test #9:

score: 0
Accepted
time: 50ms
memory: 59124kb

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
99002 99871
99455 99935
98568 98703
98775 99014
99051 99295
98330 98794
98596 98666
98613 98728
98537 98949
98269 98494
99308 99531
99464 99767
98981 99431
97660 97740
96790 97318
99570 99947
96958 97178
99555 99682
99413 99718
99690 99797
98907 99288
98180 99419
98556 98832
98632 99216
99684 99...

result:

ok Correct.

Test #10:

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

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
98805 99672
98016 98458
98030 98307
96964 97211
98406 99646
96353 99283
96874 97770
95149 95528
95727 95009
95032 95826
92731 93287
92589 93509
94115 94816
91889 92036
91071 99808
91183 98582
93463 93894
90894 95056
88023 88429
90013 93053
89615 91559
90450 91513
87571 88651
87267 88524
87179 89...

result:

ok Correct.

Test #11:

score: 0
Accepted
time: 40ms
memory: 55160kb

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
24098 80198
24783 88171
11139 40562
29042 73062
65243 99142
78891 93050
50504 79869
36153 68751
63196 83117
17788 79302
6386 60234
46536 98139
15034 48385
15842 57729
37679 61505
35563 67516
29431 89988
7572 78374
46167 96843
5629 37345
20243 73598
42327 55234
14379 60615
28006 94930
58735 62595...

result:

ok Correct.

Test #12:

score: 0
Accepted
time: 34ms
memory: 53628kb

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
24514 99253
15102 66302
37177 40113
67735 67876
70745 98880
39981 74239
13515 71421
13573 72747
49326 65914
5659 66307
6751 74307
68801 93527
25142 65868
49908 92842
28268 92302
4763 10387
4231 77194
2882 41886
23941 64953
50595 65085
2766 25338
35889 92736
5973 50684
39951 75236
7638 45778
9242...

result:

ok Correct.

Test #13:

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

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
1136 15274
14063 27596
34955 38849
40110 41588
50491 54430
55203 61983
63894 69085
72241 72642
73765 75216
85544 88086
88697 95158
1197 30463
10786 18595
21493 24025
25178 30164
30800 40282
50699 52476
59910 76452
79238 86389
91441 96792
1212 35120
34098 46043
47433 49151
56601 57549
59254 65754...

result:

ok Correct.

Test #14:

score: 0
Accepted
time: 36ms
memory: 52920kb

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
51260 62964
64799 73003
87232 98672
31245 38059
47626 58383
78385 82570
84269 91105
67893 90700
95599 97507
51711 96567
2480 84425
90521 97467
3614 97387
67504 76866
48982 97376
61972 73151
90926 95255
2988 63972
3348 65309
66342 88130
40816 71350
2595 67502
5612 99364
7802 96840
92365 95951
405...

result:

ok Correct.

Test #15:

score: 0
Accepted
time: 29ms
memory: 51976kb

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
24271 32530
37384 38484
38738 38753
39458 39709
43803 46496
49018 49313
51853 53261
54125 54934
56321 59449
60751 62015
70717 81679
89831 97806
18859 26046
28373 30675
33247 34688
39921 43694
44356 46485
54712 55259
57280 57761
58304 58424
61007 61172
68370 71317
73029 73977
76662 88437
93135 97...

result:

ok Correct.

Test #16:

score: 0
Accepted
time: 37ms
memory: 54240kb

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
336 82705
60220 72014
80211 95022
93125 94029
59250 85950
77242 89854
56243 61755
80147 86382
408 37709
86818 91748
87876 89771
452 83493
481 97158
614 92488
824 95750
409 78516
598 96448
2 86064
86859 95747
78815 76526
60638 77425
34692 89238
11713 97446
4966 98648
4358 82710
4090 93523
3462 97...

result:

ok Correct.

Test #17:

score: 0
Accepted
time: 31ms
memory: 54244kb

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: 38ms
memory: 56000kb

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: 23ms
memory: 55060kb

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: 47ms
memory: 58028kb

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: 31ms
memory: 56980kb

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: 44ms
memory: 58472kb

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: 40ms
memory: 57512kb

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: 29ms
memory: 56328kb

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: 19ms
memory: 53752kb

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: 32ms
memory: 54780kb

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: 50ms
memory: 58572kb

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: 28ms
memory: 54444kb

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: 43ms
memory: 57584kb

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: 46ms
memory: 57928kb

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: 39ms
memory: 70068kb

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
99999 100000
99993 99994
99989 99992
99987 99988
99985 99986
99981 99983
99975 99976
99972 99974
99969 99970
99966 99971
99964 99965
99963 99967
99961 99962
99957 99959
99958 99960
99954 99956
99944 99945
99947 99952
99948 99949
99937 99942
99938 99939
99932 99933
99935 99936
99928 99931
99929 9...

result:

ok Correct.

Test #32:

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

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
2 71956
16519 19368
19370 20002
22372 23276
23623 23892
25053 25678
26012 26238
27219 27730
27745 28074
28638 28666
28834 29163
29193 29412
29427 29474
29584 29948
30011 30054
30281 30343
30739 30822
30976 30991
31022 31161
32140 32177
32415 32851
32863 32956
32972 33012
33083 33116
33338 33345
...

result:

ok Correct.

Test #33:

score: 0
Accepted
time: 37ms
memory: 57480kb

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
39643 66636
59669 73972
29538 39373
43825 45676
61662 92094
54079 56374
51777 58779
89214 92038
51729 79715
52001 91931
54089 59992
26175 65054
59652 65249
46097 50472
28787 37619
48367 70144
68486 73300
15616 71114
39620 87207
63988 82288
11598 31389
27837 30372
49740 36554
33598 71700
60608 76...

result:

ok Correct.

Test #34:

score: 0
Accepted
time: 44ms
memory: 59312kb

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
17095 70030
58313 71886
81302 88337
46082 61987
49044 58426
53023 69693
83035 89381
75689 87654
69877 83186
57838 76609
38920 79463
36841 46779
37289 74808
50554 86286
83917 90294
21741 55098
26076 38474
58922 83059
75306 75451
72392 80380
58108 61439
32197 41745
44566 92181
8778 87864
65888 549...

result:

ok Correct.

Test #35:

score: 0
Accepted
time: 42ms
memory: 58132kb

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
71063 90448
47226 70985
53817 54731
60928 71130
52065 60775
53816 92806
61834 78644
34925 66621
76915 91538
61559 72307
61678 77871
56059 78776
50496 61249
52856 62538
50118 54218
46399 88965
39731 56708
57283 71777
25314 68919
43914 74435
40564 73589
70446 75837
29110 53440
64465 81837
72630 92...

result:

ok Correct.

Test #36:

score: 0
Accepted
time: 59ms
memory: 59256kb

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
66577 81930
77584 83933
63072 92455
67573 71866
72371 92912
63337 70317
61159 70245
52559 94399
65297 80055
72465 85114
43588 59449
75636 85452
58621 64850
29443 31276
48922 56643
23195 51157
28814 88704
62845 89798
81017 90058
86719 94855
42364 64539
56961 92183
37510 94394
51463 66889
86374 89...

result:

ok Correct.

Test #37:

score: 0
Accepted
time: 16ms
memory: 52132kb

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
15103 16618
21994 23516
8235 16434
9591 22264
12691 21246
8616 19880
19343 20031
21772 22971
21287 24144
13423 18950
22122 22868
13258 24765
9420 16589
14003 20892
4662 12386
6480 7451
18730 23940
16708 22041
11390 12213
20929 24705
18882 25137
15277 24686
9392 12423
16897 18580
16147 17297
2373...

result:

ok Correct.

Test #38:

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

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
47101 87399
60086 84050
39053 64188
60799 73100
27729 91714
37196 51058
57410 86184
31825 88324
92590 84986
24943 87646
23925 35872
78293 89760
22558 27833
48734 67687
75253 89379
61040 83797
74594 84043
32439 35199
35795 84021
71668 88437
16888 84125
12330 22901
25486 29387
61771 77362
70333 85...

result:

ok Correct.

Test #39:

score: 0
Accepted
time: 49ms
memory: 58044kb

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
50583 64748
83879 99612
47764 55350
44945 84477
60215 65354
51254 51316
54560 59804
64777 73704
79685 89280
76854 82652
34349 61141
62762 67573
30362 80616
51451 80150
34986 63900
88309 91487
78819 99160
55300 66253
50766 70840
26423 70421
32935 60649
60238 86183
86632 97034
43300 46625
24793 30...

result:

ok Correct.

Test #40:

score: 0
Accepted
time: 51ms
memory: 58844kb

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
78156 78204
36397 51967
78133 82427
73958 79070
38876 57455
34717 43404
48285 58713
36514 37948
64018 88498
68802 72670
81149 87893
22228 85556
24511 53774
43245 61304
58325 59479
79174 88072
76311 89317
60999 83169
71803 89571
34101 50155
34710 76502
44985 65296
21100 90010
28817 53737
31035 67...

result:

ok Correct.

Test #41:

score: 0
Accepted
time: 51ms
memory: 57720kb

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
84470 85877
56796 84813
42797 88602
60185 68533
70827 81856
60101 84668
86069 92180
43585 44601
90588 90933
51632 38530
64621 66807
38876 40261
54401 71776
70527 90432
35538 67445
62691 83494
64876 87364
42123 78467
51661 57243
18333 81751
76922 87803
51577 88298
66806 74165
82624 90940
63533 91...

result:

ok Correct.

Test #42:

score: 0
Accepted
time: 51ms
memory: 58820kb

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
61403 84069
84102 92293
64473 88097
55424 81431
51261 72143
79826 86058
52423 92072
47929 63157
67233 82708
89940 91160
57962 76454
51909 57177
59297 60350
62145 85916
35934 66794
36823 50820
55573 86852
68102 69228
44978 66952
39762 75739
86019 87714
32949 88236
49775 64172
33426 49389
50738 52...

result:

ok Correct.

Test #43:

score: 0
Accepted
time: 4ms
memory: 49712kb

input:

1

output:

YES

result:

ok Correct.