QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#364822#6396. Puzzle: KusabiMaMengQiAC ✓110ms57840kbC++203.2kb2024-03-24 16:51:412024-03-24 16:51:42

詳細信息

Test #1:

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

input:

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

output:

YES
5 4
8 6

result:

ok Correct.

Test #2:

score: 0
Accepted
time: 3ms
memory: 12392kb

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

result:

ok Correct.

Test #3:

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

input:

2
2 1 Tong

output:

NO

result:

ok Correct.

Test #4:

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

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
78961 61327
92416 71315
47332 33659
78872 62962
42110 20744
97640 58531
95031 27446
24772 3681
15911 79799
76595 61255
98939 44448
72730 8187
78097 76428
85390 65956
18457 14565
91535 53748
67893 61324
41920 12963
40779 5978
78242 66078
52767 23420
61950 35692
66591 26692
41308 8200
74654 51749
...

result:

ok Correct.

Test #5:

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

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
37144 5364
3704 5004
97538 90735
98308 78598
79958 48929
90722 46933
71716 63753
52721 98336
59347 29986
65733 81832
56153 45396
69473 58166
83306 68562
90372 88026
21350 49414
84631 41691
89202 84788
57257 56790
74096 79552
43168 74763
83961 53053
22158 17151
65562 48113
94984 88647
89798 92062...

result:

ok Correct.

Test #6:

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

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
524 510
1413 1428
1350 1181
1040 1008
2293 2431
5155 4744
10291 9835
7461 8265
16801 21461
6783 7800
5478 4788
3720 3705
16751 16475
13920 16924
13739 16608
11695 10961
29385 29052
24590 29299
81180 73995
70932 70563
72818 53442
81032 75175
71794 86654
52919 45637
49360 43836
42536 41279
45005 4...

result:

ok Correct.

Test #7:

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

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
286 279
262 260
579 562
409 385
375 386
486 479
3328 3230
3177 3084
3518 3304
7564 7541
61367 45631
95979 94913
91068 89297
91209 87610
40600 38972
36114 35976
32514 33052
17565 17203
16691 16281
11094 11071
10114 9912
9567 10637
8457 9335
9379 9289
25285 23326
7535 7105
6176 6000
21161 21040
13...

result:

ok Correct.

Test #8:

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

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
430 424
353 383
429 422
707 699
787 778
757 755
1098 1097
1331 1295
1402 1388
1838 1824
1575 1573
2020 1982
2122 2126
2026 2022
2168 2223
2058 2053
3060 3026
2892 2883
3528 3465
5063 4996
4962 4946
5053 5051
5511 5368
6768 6738
12073 11984
11517 11426
15862 15724
15871 16044
16029 16010
13245 13...

result:

ok Correct.

Test #9:

score: 0
Accepted
time: 79ms
memory: 37820kb

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
738 737
1157 1154
1170 1165
1216 1220
1457 1454
1448 1450
1605 1608
1810 1832
1800 1795
2235 2242
2334 2309
2797 2772
3020 3016
2852 2851
2904 2902
3084 3076
3044 3031
3018 3025
3045 3040
3214 3212
3224 3219
3339 3299
3616 3603
3631 3607
3668 3659
3676 3663
3695 3703
3737 3733
3876 3873
3963 393...

result:

ok Correct.

Test #10:

score: 0
Accepted
time: 47ms
memory: 35332kb

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
35551 35528
85950 86202
46361 46356
4774 4758
6738 6570
12004 11802
15175 15095
16272 16218
15813 15803
17703 17698
18828 18616
20553 20479
22767 22709
25371 24981
24571 23807
23781 23319
28616 28570
27425 26536
29756 29047
30157 29822
29413 29383
31800 31792
34909 34775
34774 33210
33101 33062
...

result:

ok Correct.

Test #11:

score: 0
Accepted
time: 79ms
memory: 35700kb

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
24625 36459
51360 12629
66179 40633
77789 24756
48087 43166
40062 39212
57016 26357
64410 49932
62888 44653
54988 69476
34629 12680
93996 80336
83954 54631
72055 39440
24774 16971
62379 39572
54804 93177
30597 49129
88460 36894
51492 30724
14531 27901
53689 28655
89547 70073
66411 57242
89634 55...

result:

ok Correct.

Test #12:

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

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
89903 67589
39272 68594
81476 15090
71809 60781
6696 52694
39450 53733
38667 9364
93654 56621
56831 78483
26050 70164
82381 23972
93029 56644
96431 59869
16173 48623
11622 69879
61067 65091
97866 50064
17431 40767
66474 30022
94704 56465
51438 91780
99631 76670
36526 81510
38696 54945
67890 5756...

result:

ok Correct.

Test #13:

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

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
91412 24883
85955 13639
22212 33335
97480 35159
45927 71589
37328 50813
89522 74905
55077 93406
55068 43510
99420 38839
37375 30018
8207 16232
45202 19798
79738 21535
24169 25264
46503 33395
91816 90487
69419 58609
98717 77936
57836 53262
47484 85424
84824 36040
29503 48708
14724 60312
22670 860...

result:

ok Correct.

Test #14:

score: 0
Accepted
time: 71ms
memory: 36788kb

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
66929 95552
73534 81453
70004 69029
83456 81725
50102 45455
19960 16997
23609 51615
36674 62131
38786 44070
81033 47632
19935 8378
81272 59014
50668 72824
28348 83388
10617 77119
63648 83713
37654 38769
55371 51456
58136 80843
68781 74365
98528 66899
21156 27042
5452 79274
23421 11930
37457 6055...

result:

ok Correct.

Test #15:

score: 0
Accepted
time: 72ms
memory: 36476kb

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
81529 67080
96779 96324
81594 44807
93130 77746
95680 70258
98806 96868
95579 63689
83651 72275
92136 87183
85430 89116
96722 58256
99461 99289
53373 93152
75851 69273
33720 53725
22407 76940
44782 73938
96826 76846
92928 81411
66822 75168
74970 19863
64377 40265
76646 24515
80128 33693
70668 71...

result:

ok Correct.

Test #16:

score: 0
Accepted
time: 76ms
memory: 37852kb

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
99538 89169
94865 70230
79579 67510
72188 67027
93180 87106
84255 89663
82529 82112
37396 72639
85868 78040
57276 69028
99319 95605
90324 87186
57132 89175
91368 53018
20476 89224
63062 42452
78387 68143
42445 82034
69027 59794
79254 83490
99297 97482
97324 91080
90731 86476
63617 63175
48524 70...

result:

ok Correct.

Test #17:

score: 0
Accepted
time: 67ms
memory: 35492kb

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: 49ms
memory: 35064kb

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

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: 33ms
memory: 30516kb

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: 51ms
memory: 34760kb

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: 25ms
memory: 30768kb

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: 34ms
memory: 31644kb

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: 36ms
memory: 33404kb

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: 72ms
memory: 35372kb

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: 74ms
memory: 35884kb

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: 61ms
memory: 33240kb

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: 82ms
memory: 38148kb

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: 69ms
memory: 34664kb

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: 93ms
memory: 40132kb

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

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
67654 67653
69364 69363
82548 82546
88005 88004
88810 88808
90831 90830
93663 93661
99659 99658
99888 99886
99873 99872
99842 99841
99828 99826
99775 99774
99756 99755
99689 99688
99660 99656
99544 99542
99522 99521
99509 99508
99468 99466
99441 99439
99252 99251
99224 99223
99221 99220
99215 99...

result:

ok Correct.

Test #32:

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

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
92627 90226
98157 80552
86460 92271
96463 99736
66335 85511
67953 86134
89806 86996
94233 89512
99860 97391
95440 93512
91747 89327
74512 73888
85318 79593
92584 89757
64372 69427
48609 56615
82419 73891
60624 55714
65770 71357
92085 87691
80845 83893
81710 88314
85698 81856
82075 77025
72862 85...

result:

ok Correct.

Test #33:

score: 0
Accepted
time: 68ms
memory: 34684kb

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
56841 51464
72888 61663
53775 3134
45498 29835
30050 40518
42570 12051
39293 37967
52571 46229
71264 31359
68332 10707
86736 9382
76209 53928
27655 7179
37359 37077
46708 89013
37150 21983
70593 40146
67717 33369
78256 64726
31549 3170
66348 24096
22997 1104
74595 23363
84013 42610
30412 57633
5...

result:

ok Correct.

Test #34:

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

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
49780 13682
40542 22903
19440 35611
66749 41203
41743 16807
61610 52077
89895 61088
42279 41633
22128 7990
84810 23444
60270 42482
21595 18475
19065 10412
71531 53734
63639 37331
12528 29165
66607 26468
37774 33856
74485 43948
87555 20535
12875 63279
13794 4239
28790 4051
75225 17544
77806 55259...

result:

ok Correct.

Test #35:

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

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
58464 42330
63353 4623
77371 53894
36051 25512
72379 32196
61241 58719
40373 47115
88779 62758
13068 10619
33511 20002
63978 87036
80684 48059
91839 51748
51607 73230
58326 50097
26563 22240
17826 52892
90102 75637
49587 36241
81607 47123
42101 28691
49716 45408
51560 71628
75210 72204
68380 525...

result:

ok Correct.

Test #36:

score: 0
Accepted
time: 87ms
memory: 37684kb

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
89860 44405
86527 39400
94447 77567
37935 32809
96963 83835
70260 33489
64950 5092
45476 8634
59080 91065
50514 22251
66489 47683
79079 69211
58394 25822
91186 20355
79777 49948
38084 26939
83359 25783
68927 30285
17555 8542
33324 26414
95850 60375
80943 63110
39498 84716
94651 59837
59511 45403...

result:

ok Correct.

Test #37:

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

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
21260 14395
12166 9793
23470 16744
5426 5214
23476 21677
10676 10959
19243 12051
24399 24943
13802 9905
20299 11297
16704 6422
15928 8020
14751 14906
22959 16776
23588 22076
23242 12595
7161 3989
23892 16686
8483 23606
24077 10358
20651 19496
15460 4943
24954 19331
11694 493
17107 9545
20760 219...

result:

ok Correct.

Test #38:

score: 0
Accepted
time: 79ms
memory: 36576kb

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
46359 6191
5264 3969
32227 1308
92987 34183
40253 9990
75202 66839
55071 30136
61302 29114
31294 22811
32318 25564
37889 76337
79262 23488
79128 27511
76804 18641
81051 76872
82146 78246
67106 31929
43256 20801
84365 70950
61715 66636
76761 50411
88222 9531
72405 59474
68940 38525
91146 61061
80...

result:

ok Correct.

Test #39:

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

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
48328 24906
89962 84824
83104 76758
49895 98509
99796 20197
86508 86256
39151 3634
98550 19909
95262 32146
41953 45621
71926 69962
91090 66025
19598 12143
49476 96644
51734 29309
82185 64919
76311 40783
71569 57117
84056 97675
97144 87917
93316 93429
64048 8999
36959 45169
86399 59589
68509 1488...

result:

ok Correct.

Test #40:

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

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
47797 31347
46329 68733
53256 19496
27747 25680
54094 10884
73951 73348
55771 43634
69719 65148
87763 42519
35808 18411
31510 21560
16287 13885
45881 21740
14758 5322
75151 49471
58116 46066
71051 39893
89115 20500
29292 1148
82128 47283
45277 22581
46592 10753
75440 71499
88159 39269
27282 8616...

result:

ok Correct.

Test #41:

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

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
78212 71885
73661 57857
56423 41232
39677 13465
59214 22987
89405 68740
54383 25476
73745 48590
42520 39635
72501 40060
87247 85702
59623 14246
45163 36242
38906 20769
29754 4574
42405 32449
42448 34350
91002 85212
69191 53895
31645 20711
46265 24913
62379 21728
79184 34963
68825 56215
82472 826...

result:

ok Correct.

Test #42:

score: 0
Accepted
time: 78ms
memory: 35464kb

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
85792 61782
90866 31792
33373 31148
39242 76740
74050 63244
42443 38497
50500 80383
72828 47336
29127 23534
71407 54793
89707 81610
75873 68261
90212 90183
16191 64152
89204 71094
87719 76745
26361 23285
86179 66205
57296 65317
77840 34576
55763 21434
65615 23754
68809 52865
89910 88056
53941 30...

result:

ok Correct.

Test #43:

score: 0
Accepted
time: 3ms
memory: 11712kb

input:

1

output:

YES

result:

ok Correct.