QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#717791#9607. 熟练qiuzx100 ✓572ms165340kbC++205.1kb2024-11-06 18:57:472024-11-06 18:57:47

详细

Subtask #1:

score: 3
Accepted

Test #1:

score: 3
Accepted
time: 88ms
memory: 50108kb

input:

1
100000
1 2
1 1
1 1
3 5
1 2
2 3
2 1
2 3
1 1
1 1
3 3
1 3
1 1
1 1
1 1
4 4
1 2
2 3
3 4
3 3
2 1
3 3
4 2
5 3
1 2
1 3
1 4
2 5
1 1
3 3
3 1
1 5
1 1
1 1
1 1
1 1
1 1
2 5
1 2
2 1
1 2
1 2
1 2
1 2
2 2
1 2
2 2
2 2
4 2
1 2
1 3
1 4
4 4
2 3
2 3
1 2
1 2
1 1
1 1
1 4
1 1
1 1
1 1
1 1
5 3
1 2
2 3
3 4
4 5
3 4
4 5
5 2
2 1...

output:

2
1 2 
3
1 2 2 3 1 
3
1 2 3 
3
1 1 2 3 
2
1 1 2 
5
1 2 3 4 5 
5
1 2 3 4 5 
2
1 2 
1
1 1 
3
1 2 3 
4
1 2 3 4 
3
1 2 3 
1
1 
2
1 2 
4
1 2 3 4 
3
1 2 1 3 
3
1 2 1 3 
1
1 
2
1 2 
2
1 2 
4
1 2 3 4 
3
1 2 3 1 
4
1 2 3 4 1 
1
1 
4
1 2 3 4 
1
1 
5
1 2 3 4 5 
1
1 1 
5
1 2 3 4 5 
2
2 1 2 
3
2 1 2 3 
3
1 2 3 
...

result:

ok ok

Subtask #2:

score: 14
Accepted

Dependency #1:

100%
Accepted

Test #2:

score: 14
Accepted
time: 58ms
memory: 92352kb

input:

2
1005
489417 5
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
5 11
6 12
6 13
7 14
7 15
8 16
8 17
9 18
9 19
10 20
10 21
11 22
11 23
12 24
12 25
13 26
13 27
14 28
14 29
15 30
15 31
16 32
16 33
17 34
17 35
18 36
18 37
19 38
19 39
20 40
20 41
21 42
21 43
22 44
22 45
23 46
23 47
24 48
24 49
25 50
25 51
26 52
26 5...

output:

4
1 2 2 3 4 
4
1 2 3 1 4 
3
1 1 1 2 3 
3
1 2 2 2 3 
4
1 2 3 4 
3
1 2 3 1 1 
4
1 2 3 4 
3
1 1 2 2 3 
4
1 2 3 4 
4
1 2 3 3 4 
3
1 2 1 3 
4
1 2 3 4 
5
1 2 3 4 5 
3
1 2 1 3 2 
5
1 2 3 4 5 
5
1 2 3 4 5 
4
1 2 3 4 
3
1 2 3 3 
4
1 2 3 4 
4
1 2 3 4 
4
1 2 2 3 4 
5
1 2 3 4 5 
3
1 1 2 3 2 
2
1 1 2 2 
5
1 2 3 ...

result:

ok ok

Test #3:

score: 14
Accepted
time: 124ms
memory: 103168kb

input:

2
9250
403459 5
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
5...

output:

5
1 2 3 4 5 
4
3 1 2 3 4 
4
1 2 3 4 
4
1 2 3 4 
2
1 1 1 2 
4
1 2 3 4 
5
1 2 3 4 5 
3
1 1 2 2 3 
2
1 1 1 2 
4
1 2 3 4 
2
1 1 2 1 
4
1 2 3 3 4 
3
1 1 1 2 3 
4
1 2 3 4 
3
1 2 1 1 3 
2
1 1 2 2 1 
4
1 2 3 4 1 
3
1 2 1 3 
4
1 2 3 4 
3
1 1 1 2 3 
3
1 1 2 3 
5
1 2 3 4 5 
4
1 2 1 3 4 
2
1 1 2 2 
4
1 2 1 3 4 ...

result:

ok ok

Test #4:

score: 14
Accepted
time: 65ms
memory: 78572kb

input:

2
120
55394 5
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 ...

output:

3
1 1 1 2 3 
2
1 1 2 1 2 
4
2 1 2 3 4 
4
1 1 2 3 4 
4
1 2 3 3 4 
3
1 2 2 3 1 
5
1 2 3 4 5 
4
1 2 3 4 
3
1 2 2 3 
3
1 2 3 1 
2
1 2 1 1 
3
1 1 2 3 3 
5
1 2 3 4 5 
5
1 2 3 4 5 
4
1 2 3 4 
3
1 2 2 3 
3
1 1 2 3 
3
1 1 2 3 
4
1 2 3 1 4 
5
1 2 3 4 5 
4
1 2 1 3 4 
3
1 2 2 3 3 
3
1 2 3 1 
5
1 2 3 4 5 
4
1 2 ...

result:

ok ok

Test #5:

score: 14
Accepted
time: 91ms
memory: 75916kb

input:

2
6024
82100 5
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
5 13
10 14
8 15
6 16
15 17
3 18
9 19
14 20
19 21
4 22
1 23
22 24
21 25
25 26
11 27
18 28
23 29
7 30
26 31
12 32
2 33
29 34
17 35
34 36
31 37
32 38
13 39
30 40
36 41
33 42
41 43
40 44
16 45
42 46
39 47
20 48
48 49
43 50
46 51
37 52
52 53
4...

output:

5
1 2 3 4 5 
4
1 2 1 3 4 
4
1 2 1 3 4 
4
1 1 2 3 4 
4
1 2 3 1 4 
3
1 2 2 3 
3
1 1 2 3 
3
1 1 2 3 
5
1 2 3 4 5 
3
1 1 2 3 
4
1 2 3 4 
3
1 1 2 3 
3
1 2 2 3 
3
3 2 1 2 3 
4
1 1 2 3 4 
4
2 1 2 3 4 
4
1 2 3 4 
2
1 1 1 2 
5
1 2 3 4 5 
3
1 2 2 3 3 
5
1 2 3 4 5 
4
1 2 3 4 
5
1 2 3 4 5 
3
1 3 2 3 
4
1 2 3 1 ...

result:

ok ok

Test #6:

score: 14
Accepted
time: 46ms
memory: 51532kb

input:

2
483
2200 5
1 2
2 3
1 4
4 5
2 6
2 7
1 8
5 9
7 10
5 11
8 12
3 13
2 14
2 15
1 16
9 17
5 18
6 19
7 20
2 21
3 22
7 23
9 24
11 25
3 26
10 27
11 28
7 29
3 30
3 31
7 32
12 33
1 34
8 35
1 36
8 37
11 38
11 39
3 40
11 41
3 42
10 43
11 44
7 45
9 46
7 47
8 48
7 49
5 50
8 51
9 52
4 53
8 54
11 55
2 56
2 57
8 58
...

output:

4
1 2 3 4 1 
2
1 2 2 2 1 
2
1 1 1 2 2 
4
1 2 1 3 4 
4
1 2 3 2 4 
3
1 2 3 1 2 
5
1 2 3 4 5 
4
1 2 2 3 4 
4
1 1 2 3 4 
4
1 1 2 3 4 
5
1 2 3 4 5 
5
1 2 3 4 5 
4
1 2 2 3 4 
3
1 1 2 1 3 
3
1 2 1 3 1 
2
1 2 2 1 2 
2
1 1 1 2 1 
3
1 2 1 1 3 
3
1 3 3 2 3 
5
1 2 3 4 5 
5
1 2 3 4 5 
4
1 2 3 3 4 
3
1 3 2 3 1 
3...

result:

ok ok

Test #7:

score: 14
Accepted
time: 37ms
memory: 53660kb

input:

2
400
2260 5
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 5...

output:

3
1 2 3 2 3 
4
1 1 2 3 4 
5
1 2 3 4 5 
4
1 1 2 3 4 
3
3 3 1 2 3 
5
1 2 3 4 5 
4
1 2 3 1 4 
4
1 2 3 2 4 
5
1 2 3 4 5 
4
1 1 2 3 4 
5
1 2 3 4 5 
5
1 2 3 4 5 
4
1 1 2 3 4 
4
1 2 3 4 4 
3
1 1 2 2 3 
3
2 1 2 3 3 
3
2 1 2 1 3 
5
1 2 3 4 5 
5
1 2 3 4 5 
5
1 2 3 4 5 
3
2 1 1 2 3 
4
1 2 3 4 1 
3
1 2 2 1 3 
5...

result:

ok ok

Test #8:

score: 14
Accepted
time: 72ms
memory: 76760kb

input:

2
9990
124660 5
1 2
2 3
1 4
4 5
4 6
1 7
6 8
7 9
8 10
1 11
7 12
6 13
8 14
11 15
5 16
12 17
6 18
9 19
17 20
13 21
21 22
20 23
15 24
16 25
10 26
7 27
6 28
1 29
8 30
26 31
17 32
13 33
18 34
13 35
9 36
18 37
28 38
18 39
34 40
10 41
30 42
9 43
17 44
37 45
5 46
26 47
15 48
6 49
28 50
19 51
15 52
45 53
36 5...

output:

4
1 2 3 4 1 
4
1 2 2 3 4 
5
1 2 3 4 5 
5
1 2 3 4 5 
4
1 2 3 4 
4
1 2 3 4 1 
5
1 2 3 4 5 
4
1 1 2 3 4 
4
1 3 2 3 4 
4
1 1 2 3 4 
4
1 2 2 3 4 
2
1 1 1 2 
3
1 2 1 2 3 
4
1 2 3 4 1 
3
1 2 3 1 
3
1 1 2 3 
3
1 2 3 3 2 
4
1 1 2 3 4 
5
1 2 3 4 5 
3
1 2 3 3 
3
1 1 2 2 3 
4
1 2 3 2 4 
4
1 2 3 4 
4
2 1 2 3 4 
...

result:

ok ok

Test #9:

score: 14
Accepted
time: 106ms
memory: 75292kb

input:

2
9078
76509 5
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51...

output:

3
1 2 2 3 1 
4
1 2 3 4 1 
4
1 2 3 1 4 
5
1 2 3 4 5 
3
1 3 2 3 
5
1 2 3 4 5 
4
1 2 3 4 
4
1 1 2 3 4 
4
1 1 2 3 4 
2
1 1 2 2 
4
1 1 2 3 4 
4
1 2 3 4 
5
1 2 3 4 5 
4
1 2 3 4 
4
1 2 3 4 
5
1 2 3 4 5 
5
1 2 3 4 5 
3
2 1 2 2 3 
4
1 2 3 4 1 
3
1 2 1 2 3 
4
1 2 3 4 
5
1 2 3 4 5 
3
1 1 2 3 2 
3
1 1 2 2 3 
4
...

result:

ok ok

Test #10:

score: 14
Accepted
time: 170ms
memory: 91548kb

input:

2
4147
456368 5
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
6 12
3 13
11 14
5 15
14 16
15 17
13 18
10 19
17 20
2 21
12 22
20 23
9 24
22 25
19 26
25 27
26 28
4 29
8 30
24 31
1 32
16 33
31 34
29 35
34 36
27 37
33 38
38 39
28 40
35 41
18 42
41 43
39 44
7 45
44 46
40 47
37 48
21 49
36 50
46 51
45 52
32 53...

output:

5
1 2 3 4 5 
5
1 2 3 4 5 
4
1 2 3 4 3 
3
3 1 2 3 
4
1 1 2 3 4 
3
1 2 3 1 
4
1 2 2 3 4 
4
1 2 3 4 
5
1 2 3 4 5 
4
1 2 3 4 
4
1 2 3 4 
5
1 2 3 4 5 
3
1 1 2 1 3 
5
1 2 3 4 5 
3
1 1 2 3 
2
2 1 1 2 
3
1 2 3 2 
3
3 1 2 3 2 
4
1 2 3 4 
5
1 2 3 4 5 
3
2 1 2 3 
4
1 4 2 3 4 
4
1 2 3 4 
5
1 2 3 4 5 
3
1 1 2 3 ...

result:

ok ok

Subtask #3:

score: 9
Accepted

Test #11:

score: 9
Accepted
time: 269ms
memory: 163472kb

input:

3
1769
481318 428631
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50...

output:

66
1 21 2 3 6 50 4 8 5 48 6 7 1 25 8 9 4 10 15 11 32 12 13 14 15 16 6 17 18 19 20 4 21 32 23 22 23 24 27 24 25 26 27 28 29 27 15 18 20 30 31 32 33 10 34 38 35 36 33 9 12 16 11 37 2 3 10 20 38 39 34 3 6 40 41 51 3 42 7 21 43 44 45 46 11 27 47 4 11 8 14 9 48 49 58 50 51 45 36 5 27 1 52 53 7 1 7 5 3 54...

result:

ok ok

Test #12:

score: 9
Accepted
time: 167ms
memory: 92420kb

input:

3
5246
78503 54670
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 5...

output:

12758
1 2 250 3 342 979 4 14 5 6 6005 724 7 3115 8 9 1048 10 11 12 1753 181 824 711 13 218 3501 14 15 16 2286 17 2749 18 19 1685 25 3783 20 6785 21 22 23 24 25 10123 553 5552 1115 26 27 28 29 30 31 32 328 33 691 611 34 810 35 36 37 38 222 39 40 1384 41 423 42 252 43 2230 119 44 45 46 1795 47 10017 4...

result:

ok ok

Test #13:

score: 9
Accepted
time: 119ms
memory: 53028kb

input:

3
396
1125 1442
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
5...

output:

160
48 1 58 126 2 3 4 147 5 101 49 6 7 8 9 10 143 16 11 96 12 13 31 14 90 29 15 91 16 17 18 10 131 19 6 96 20 37 28 21 95 24 24 7 22 15 9 89 23 24 38 16 25 26 37 27 25 35 28 12 29 30 31 32 67 33 34 6 35 101 123 36 36 118 37 16 115 14 46 38 39 112 123 12 40 41 42 43 15 44 109 45 46 140 103 47 48 75 4...

result:

ok ok

Test #14:

score: 9
Accepted
time: 119ms
memory: 53188kb

input:

3
487
1664 2238
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
5...

output:

558
35 547 1 2 200 196 168 284 147 3 4 5 382 6 178 94 74 336 336 201 4 7 8 17 363 9 10 60 11 249 74 12 119 13 14 15 16 17 284 18 19 20 21 51 22 27 200 59 23 24 57 25 127 26 27 28 106 132 29 440 30 23 8 22 304 66 544 462 31 32 33 34 111 18 35 36 37 38 39 136 40 86 41 3 21 17 197 52 42 43 25 44 45 5 4...

result:

ok ok

Test #15:

score: 9
Accepted
time: 308ms
memory: 165340kb

input:

3
130
498610 459330
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 ...

output:

28970
1 2 3 4 2821 9547 5820 14038 480 2856 5 11211 5729 1269 6419 3800 10772 27051 12032 21203 16088 12479 24605 3664 9811 7412 7680 12616 7109 1957 5869 1374 25392 11124 1489 22739 4794 4798 2532 13550 17029 21511 5740 7189 21713 17778 1153 169 19219 15401 15860 3014 2811 6 16580 7 20303 7007 4330...

result:

ok ok

Test #16:

score: 9
Accepted
time: 276ms
memory: 161216kb

input:

3
3566
462541 448340
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50...

output:

183
1 2 3 4 73 5 6 7 87 24 8 9 111 10 52 137 132 11 88 13 62 123 12 134 13 14 24 93 15 47 16 17 18 143 19 20 21 22 23 46 115 24 20 25 26 27 29 28 29 12 30 31 32 124 92 33 34 35 13 36 37 120 38 39 40 41 12 42 43 44 41 8 4 169 8 143 45 46 90 47 48 116 49 50 51 71 52 53 3 54 13 27 7 55 56 3 57 58 59 92...

result:

ok ok

Subtask #4:

score: 20
Accepted

Test #17:

score: 20
Accepted
time: 3ms
memory: 45096kb

input:

4
37
923 917
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
10 13
4 14
11 15
9 16
8 17
5 18
18 19
2 20
13 21
12 22
14 23
19 24
3 25
16 26
15 27
22 28
28 29
21 30
6 31
31 32
23 33
1 34
17 35
30 36
26 37
37 38
34 39
20 40
40 41
39 42
41 43
38 44
24 45
33 46
42 47
25 48
45 49
29 50
36 51
48 52
43 53
51...

output:

839
1 1 2 2 3 4 5 6 7 8 1 9 10 11 12 13 14 15 16 17 18 1 19 20 1 21 22 23 24 2 25 26 27 28 2 29 1 30 1 31 32 33 34 35 36 37 38 7 39 40 41 42 43 44 45 46 47 8 48 49 50 51 52 53 54 55 1 56 57 1 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 2 1 78 79 80 81 82 83 84 85 86 8 87 88 89 90 91 ...

result:

ok ok

Test #18:

score: 20
Accepted
time: 5ms
memory: 45028kb

input:

4
26
910 955
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 5...

output:

417
28 257 1 2 3 4 126 11 5 69 128 172 6 7 8 9 21 30 10 45 183 11 15 86 12 13 90 14 15 33 46 16 17 126 18 19 20 21 73 22 23 79 24 25 26 27 28 8 6 29 30 31 1 32 33 34 78 35 84 36 37 40 38 108 31 36 46 19 51 88 38 9 48 39 40 41 42 43 45 44 10 45 191 46 26 79 106 47 48 49 136 220 50 51 175 52 53 160 54...

result:

ok ok

Test #19:

score: 20
Accepted
time: 3ms
memory: 45128kb

input:

4
27
932 945
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
5 11
6 12
6 13
7 14
7 15
8 16
8 17
9 18
9 19
10 20
10 21
11 22
11 23
12 24
12 25
13 26
13 27
14 28
14 29
15 30
15 31
16 32
16 33
17 34
17 35
18 36
18 37
19 38
19 39
20 40
20 41
21 42
21 43
22 44
22 45
23 46
23 47
24 48
24 49
25 50
25 51
26 52
26 53
2...

output:

161
8 13 1 1 29 20 8 13 2 2 13 2 1 3 3 127 2 18 1 4 5 1 6 32 19 7 1 2 8 9 3 10 11 36 2 6 12 4 3 20 13 5 1 127 14 7 7 4 3 20 21 9 8 6 3 128 22 4 5 7 15 4 5 6 16 7 3 1 1 127 8 23 5 1 9 9 17 1 10 11 24 12 8 2 128 10 3 14 2 18 10 11 15 16 17 4 7 19 2 1 5 25 12 62 4 26 1 20 27 28 119 13 18 29 19 127 128 ...

result:

ok ok

Test #20:

score: 20
Accepted
time: 3ms
memory: 47180kb

input:

4
27
915 930
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 5...

output:

473
1 7 201 6 96 2 54 3 4 5 62 35 6 7 29 83 8 9 10 11 12 13 14 7 15 16 92 17 147 125 61 69 18 19 20 84 53 21 10 22 23 24 25 26 181 274 125 32 44 31 32 27 28 29 6 103 30 31 37 161 1 86 32 209 146 33 34 35 36 143 87 15 142 153 37 38 39 40 28 200 41 42 93 76 191 43 88 42 92 44 111 10 45 17 46 4 97 47 5...

result:

ok ok

Test #21:

score: 20
Accepted
time: 5ms
memory: 47084kb

input:

4
20
966 940
1 2
2 3
1 4
4 5
5 6
2 7
2 8
6 9
2 10
10 11
3 12
4 13
6 14
11 15
2 16
1 17
13 18
15 19
16 20
16 21
20 22
5 23
6 24
18 25
21 26
18 27
18 28
7 29
25 30
29 31
21 32
3 33
4 34
32 35
16 36
14 37
15 38
16 39
17 40
4 41
7 42
22 43
1 44
33 45
31 46
37 47
15 48
5 49
30 50
43 51
16 52
47 53
13 54
...

output:

196
1 2 3 4 5 6 7 8 9 10 11 3 12 13 14 11 2 15 16 17 18 19 3 20 21 22 23 2 24 25 26 27 1 28 29 30 31 32 3 33 34 4 35 1 36 37 38 39 40 41 42 1 43 1 44 7 45 46 47 48 49 1 50 51 13 52 53 54 55 4 56 57 14 58 59 17 60 61 62 63 64 65 3 66 67 68 69 70 71 72 73 74 75 76 77 18 2 78 79 80 2 81 82 83 4 84 4 21...

result:

ok ok

Test #22:

score: 20
Accepted
time: 5ms
memory: 42964kb

input:

4
28
920 959
1 2
2 3
1 4
3 5
2 6
4 7
6 8
3 9
4 10
6 11
11 12
8 13
3 14
4 15
8 16
13 17
3 18
17 19
11 20
14 21
7 22
19 23
7 24
12 25
3 26
12 27
22 28
9 29
15 30
17 31
14 32
8 33
2 34
7 35
12 36
13 37
22 38
25 39
20 40
37 41
11 42
29 43
17 44
23 45
36 46
7 47
27 48
24 49
30 50
28 51
17 52
26 53
46 54
...

output:

216
1 2 3 1 4 5 2 3 6 7 5 2 8 9 10 4 11 12 15 19 20 13 14 30 15 16 2 17 2 18 19 2 20 21 22 23 3 7 1 24 25 38 48 26 3 50 56 5 27 28 57 1 60 3 1 29 6 30 31 5 32 33 62 34 7 35 36 37 9 10 38 39 40 41 42 63 43 44 68 45 46 47 48 49 50 51 52 77 82 6 8 3 53 54 83 55 12 56 57 1 4 58 59 51 60 61 85 52 62 63 6...

result:

ok ok

Test #23:

score: 20
Accepted
time: 5ms
memory: 45096kb

input:

4
24
935 984
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 5...

output:

175
1 2 25 3 7 4 46 65 30 39 36 5 6 168 7 8 1 9 10 11 12 47 38 13 14 15 56 87 26 9 57 44 16 17 40 18 40 36 19 54 54 145 18 20 21 160 30 40 22 23 152 24 25 45 26 26 27 28 29 62 30 3 31 32 33 34 139 12 35 36 37 38 6 39 40 41 142 76 42 43 1 28 31 96 44 45 46 47 48 49 14 14 5 165 50 150 51 19 7 52 158 1...

result:

ok ok

Test #24:

score: 20
Accepted
time: 5ms
memory: 47104kb

input:

4
31
919 917
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
5 11
6 12
6 13
7 14
7 15
8 16
8 17
9 18
9 19
10 20
10 21
11 22
11 23
12 24
12 25
13 26
13 27
14 28
14 29
15 30
15 31
16 32
16 33
17 34
17 35
18 36
18 37
19 38
19 39
20 40
20 41
21 42
21 43
22 44
22 45
23 46
23 47
24 48
24 49
25 50
25 51
26 52
26 53
2...

output:

588
1 2 9 20 2 22 3 4 5 1 6 7 8 9 10 2 11 4 23 12 13 26 14 15 16 17 33 18 19 1 20 21 22 23 24 25 26 41 27 28 6 7 2 29 30 31 32 33 3 34 35 36 37 38 39 40 41 42 43 1 5 44 45 46 47 48 43 8 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 44 65 6 46 66 67 10 68 69 70 47 2 5 71 72 73 74 50 75 76 77 54 63 ...

result:

ok ok

Test #25:

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

input:

4
22
986 926
1 2
2 3
1 4
2 5
4 6
6 7
3 8
5 9
7 10
4 11
3 12
4 13
7 14
5 15
3 16
8 17
1 18
8 19
3 20
1 21
5 22
2 23
4 24
8 25
4 26
3 27
2 28
1 29
4 30
2 31
2 32
5 33
3 34
6 35
5 36
5 37
6 38
1 39
8 40
5 41
6 42
3 43
8 44
1 45
8 46
6 47
8 48
4 49
6 50
3 51
8 52
7 53
4 54
5 55
6 56
5 57
4 58
8 59
2 60
...

output:

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

result:

ok ok

Test #26:

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

input:

4
22
931 950
1 2
1 3
2 4
3 5
3 6
2 7
6 8
3 9
7 10
7 11
8 12
5 13
3 14
4 15
2 16
3 17
8 18
1 19
3 20
5 21
5 22
6 23
8 24
3 25
1 26
8 27
8 28
8 29
5 30
6 31
4 32
6 33
3 34
8 35
6 36
6 37
7 38
2 39
3 40
8 41
8 42
3 43
8 44
5 45
6 46
7 47
2 48
2 49
1 50
4 51
7 52
7 53
6 54
3 55
3 56
5 57
1 58
5 59
7 60
...

output:

648
1 3 2 3 4 5 6 2 1 7 8 6 5 9 10 10 11 11 12 13 14 15 16 17 2 18 3 19 20 21 16 22 23 5 2 24 25 20 26 27 28 29 30 31 13 32 33 18 34 35 4 36 25 3 37 39 29 38 39 40 8 30 41 42 43 5 44 45 46 47 7 48 49 32 4 33 50 51 9 52 53 54 55 56 46 57 47 58 59 60 61 1 62 48 63 2 64 65 66 67 50 68 69 70 71 72 73 74...

result:

ok ok

Test #27:

score: 20
Accepted
time: 3ms
memory: 45048kb

input:

4
24
990 970
1 2
2 3
3 4
4 5
4 6
3 7
5 8
6 9
2 10
2 11
5 12
3 13
4 14
6 15
9 16
7 17
3 18
17 19
10 20
7 21
12 22
2 23
13 24
23 25
20 26
26 27
20 28
11 29
16 30
16 31
16 32
1 33
31 34
26 35
24 36
24 37
13 38
12 39
15 40
29 41
33 42
21 43
6 44
44 45
10 46
29 47
24 48
24 49
30 50
6 51
12 52
21 53
26 54...

output:

675
3 1 1 2 1 3 4 5 6 7 2 4 4 8 1 9 6 10 11 12 13 18 14 15 6 4 7 16 17 18 19 20 21 22 23 24 4 25 26 5 13 27 28 6 29 30 2 31 32 33 34 35 36 37 38 16 3 39 40 41 42 19 43 44 45 46 47 23 48 29 49 50 51 52 53 54 55 56 57 58 3 30 59 60 61 15 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 2...

result:

ok ok

Test #28:

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

input:

4
22
971 961
1 2
2 3
1 4
3 5
4 6
6 7
2 8
3 9
2 10
10 11
8 12
11 13
11 14
9 15
9 16
8 17
8 18
10 19
10 20
20 21
13 22
10 23
12 24
12 25
23 26
4 27
18 28
23 29
4 30
5 31
19 32
7 33
20 34
7 35
4 36
36 37
28 38
14 39
15 40
14 41
34 42
19 43
33 44
3 45
33 46
35 47
31 48
9 49
42 50
8 51
36 52
27 53
44 54
...

output:

377
1 2 3 4 1 4 5 6 7 3 5 8 9 5 1 10 9 11 12 13 14 7 15 16 17 1 1 18 19 20 2 21 5 22 23 24 25 6 10 26 27 28 29 30 31 32 33 6 34 1 35 36 13 37 14 38 39 40 41 42 11 43 44 45 36 46 1 47 48 49 1 50 51 52 53 54 15 55 2 56 57 58 16 1 8 59 60 61 11 2 62 6 37 63 64 65 66 4 67 68 69 20 70 71 41 72 73 74 4 42...

result:

ok ok

Test #29:

score: 20
Accepted
time: 3ms
memory: 47252kb

input:

4
25
994 999
1 2
1 3
1 4
1 5
1 6
1 7
1 8
8 9
3 10
7 11
9 12
1 13
12 14
11 15
15 16
5 17
16 18
13 19
6 20
4 21
17 22
19 23
2 24
10 25
23 26
20 27
24 28
27 29
18 30
22 31
31 32
32 33
14 34
34 35
26 36
36 37
29 38
21 39
30 40
39 41
28 42
35 43
41 44
25 45
33 46
44 47
42 48
38 49
40 50
50 51
46 52
45 53...

output:

261
2 1 2 3 4 5 6 7 8 9 10 10 11 12 13 14 15 16 17 18 19 20 21 1 22 23 9 24 9 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 2 3 55 56 57 58 59 2 60 61 62 63 64 65 66 67 3 68 69 70 71 2 1 72 73 74 75 76 77 78 79 80 6 81 82 83 84 85 86 87 88 89 90 9 91 92 93...

result:

ok ok

Test #30:

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

input:

4
31
943 994
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 5...

output:

34
4 1 18 11 13 1 6 17 5 9 8 7 26 1 7 15 17 9 7 3 9 6 6 4 2 12 15 16 10 8 23 7 10 8 2 16 9 1 20 28 13 2 21 10 10 31 10 11 10 10 4 7 13 5 2 9 10 12 11 9 17 18 11 16 6 15 3 16 3 20 32 19 13 12 11 11 6 1 3 20 2 4 18 3 16 7 17 25 18 9 5 6 5 1 6 10 9 1 4 20 12 30 4 18 3 2 3 15 25 1 5 12 2 2 7 8 11 13 5 1...

result:

ok ok

Test #31:

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

input:

4
27
981 972
1 2
1 3
2 4
3 5
5 6
6 7
7 8
1 9
9 10
4 11
11 12
8 13
13 14
14 15
15 16
12 17
16 18
17 19
10 20
20 21
19 22
18 23
21 24
22 25
25 26
23 27
24 28
27 29
29 30
30 31
31 32
28 33
32 34
33 35
35 36
26 37
34 38
38 39
39 40
36 41
41 42
40 43
42 44
37 45
43 46
46 47
44 48
45 49
49 50
50 51
47 52
...

output:

19
1 6 2 3 7 8 4 5 6 3 3 6 1 7 1 1 1 8 6 1 6 7 4 7 6 1 1 4 1 1 1 8 1 1 1 1 6 1 2 1 1 7 4 1 1 1 6 10 5 3 7 1 2 1 6 8 1 2 1 1 1 7 5 3 1 3 1 5 9 1 1 8 1 10 7 1 2 1 11 8 1 1 6 1 7 1 7 2 3 2 1 1 1 7 2 1 1 7 7 1 9 4 1 6 2 3 1 2 1 9 1 3 4 1 4 1 2 6 6 1 1 5 1 1 7 2 1 9 1 1 8 3 9 9 2 6 5 4 1 3 4 1 1 3 2 2 9 ...

result:

ok ok

Test #32:

score: 20
Accepted
time: 3ms
memory: 45072kb

input:

4
27
941 912
1 2
1 3
2 4
3 5
1 6
5 7
1 8
8 9
6 10
1 11
2 12
10 13
3 14
12 15
7 16
1 17
13 18
12 19
6 20
13 21
14 22
16 23
1 24
11 25
16 26
9 27
4 28
1 29
2 30
2 31
4 32
14 33
7 34
7 35
5 36
7 37
7 38
15 39
1 40
5 41
5 42
11 43
7 44
15 45
17 46
3 47
11 48
5 49
13 50
4 51
14 52
6 53
6 54
8 55
2 56
1 5...

output:

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

result:

ok ok

Subtask #5:

score: 22
Accepted

Dependency #4:

100%
Accepted

Test #33:

score: 22
Accepted
time: 78ms
memory: 78932kb

input:

5
496
94286 94269
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
9 12
4 13
3 14
13 15
1 16
5 17
16 18
15 19
18 20
2 21
10 22
12 23
23 24
14 25
19 26
20 27
26 28
8 29
29 30
27 31
21 32
25 33
28 34
22 35
30 36
17 37
32 38
33 39
7 40
38 41
37 42
39 43
11 44
44 45
35 46
40 47
41 48
43 49
24 50
34 51
45 52
47...

output:

27238
1 2 3 4 124 54 5 139 6 7 8 9 10 11 12 13 14 15 16 97 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 37 40 41 123 42 43 44 45 46 91 47 48 44 49 50 51 52 53 54 55 56 57 58 59 60 61 62 40 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 ...

result:

ok ok

Test #34:

score: 22
Accepted
time: 91ms
memory: 80564kb

input:

5
102
87302 98915
1 2
2 3
3 4
4 5
1 6
2 7
3 8
1 9
7 10
3 11
9 12
5 13
2 14
13 15
3 16
9 17
7 18
13 19
19 20
16 21
4 22
20 23
14 24
18 25
17 26
26 27
7 28
4 29
3 30
28 31
16 32
32 33
5 34
13 35
17 36
10 37
19 38
14 39
22 40
22 41
36 42
25 43
43 44
12 45
6 46
33 47
24 48
38 49
8 50
31 51
26 52
47 53
2...

output:

43611
3 1 2 3 4 5 6 7 8 5 9 10 11 12 1 3 13 14 15 16 17 6 18 7 19 8 20 21 1 22 23 24 11 25 26 12 27 15 28 29 30 2 31 32 18 19 33 34 35 4 36 37 38 39 40 25 1 41 42 43 44 45 46 1 47 48 49 28 50 5 2 4 51 5 33 52 1 53 11 54 16 55 40 56 57 20 58 59 60 61 62 8 4 63 22 24 64 29 65 66 67 5 30 68 69 41 70 71...

result:

ok ok

Test #35:

score: 22
Accepted
time: 86ms
memory: 84832kb

input:

5
465
95072 88256
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
5 11
6 12
6 13
7 14
7 15
8 16
8 17
9 18
9 19
10 20
10 21
11 22
11 23
12 24
12 25
13 26
13 27
14 28
14 29
15 30
15 31
16 32
16 33
17 34
17 35
18 36
18 37
19 38
19 39
20 40
20 41
21 42
21 43
22 44
22 45
23 46
23 47
24 48
24 49
25 50
25 51
26 52
26...

output:

58693
1 4 2 3 7 4 11 2 5 6 7 8 9 10 11 12 13 14 15 2 16 3 1 4 17 18 19 20 12 21 22 23 24 25 26 6 8 27 9 3 28 29 30 31 32 33 1 34 35 36 17 37 38 39 40 41 42 43 3 7 44 7 9 45 46 47 1 48 49 50 1 13 51 52 53 54 55 6 56 57 58 15 5 21 59 10 60 18 61 62 63 3 64 65 66 28 67 10 68 69 2 70 6 71 8 72 73 74 75 ...

result:

ok ok

Test #36:

score: 22
Accepted
time: 27ms
memory: 57648kb

input:

5
911
9670 12225
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
8 11
6 12
5 13
4 14
7 15
9 16
16 17
11 18
1 19
14 20
15 21
13 22
3 23
20 24
12 25
24 26
26 27
23 28
18 29
27 30
22 31
2 32
19 33
32 34
25 35
34 36
29 37
10 38
28 39
33 40
30 41
38 42
17 43
41 44
36 45
37 46
45 47
40 48
44 49
48 50
50 51
51 52
49 ...

output:

11000
1 2 3 4 9 5 6 3 7 8 9 10 11 12 26 13 14 17 15 20 16 17 18 19 20 21 22 23 24 25 26 38 27 28 4 29 30 31 32 67 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 4 58 51 59 60 61 62 21 63 64 65 66 67 68 69 70 71 38 72 73 74 75 76 77 78 79 80 81 82 83 84 72 85 86 87 88 89 9...

result:

ok ok

Test #37:

score: 22
Accepted
time: 35ms
memory: 59888kb

input:

5
1077
7078 10459
1 2
1 3
3 4
2 5
3 6
4 7
7 8
3 9
4 10
7 11
9 12
1 13
2 14
8 15
6 16
5 17
5 18
11 19
6 20
14 21
8 22
11 23
12 24
15 25
10 26
10 27
7 28
2 29
7 30
1 31
14 32
7 33
1 34
13 35
11 36
5 37
11 38
8 39
3 40
14 41
3 42
7 43
14 44
6 45
11 46
8 47
13 48
9 49
6 50
4 51
10 52
2 53
12 54
14 55
10...

output:

3386
1 2 3 4 5 3 6 6 7 8 9 10 11 12 1 13 14 1 15 16 17 18 19 20 1 21 2 22 23 9 24 25 1 26 27 28 29 10 11 30 31 4 32 33 34 35 4 36 37 38 39 7 12 40 41 42 43 44 45 46 1 6 47 48 49 50 51 52 53 54 55 7 56 57 58 59 60 61 62 63 64 8 3 65 66 6 5 67 68 69 70 71 72 73 74 75 76 7 9 77 8 78 79 80 81 82 83 9 16...

result:

ok ok

Test #38:

score: 22
Accepted
time: 52ms
memory: 63988kb

input:

5
942
12731 14938
1 2
2 3
3 4
3 5
2 6
1 7
2 8
4 9
4 10
7 11
7 12
4 13
8 14
6 15
4 16
2 17
10 18
4 19
9 20
3 21
17 22
14 23
6 24
20 25
2 26
3 27
22 28
7 29
15 30
27 31
5 32
19 33
6 34
31 35
11 36
33 37
21 38
10 39
34 40
6 41
20 42
19 43
22 44
27 45
41 46
27 47
34 48
36 49
49 50
26 51
47 52
25 53
35 5...

output:

1051
1 1 10 13 13 1 2 14 36 19 3 5 21 18 35 6 39 7 8 44 4 1 9 62 2 10 48 11 12 1 14 60 21 22 15 61 16 64 67 2 4 23 17 93 24 18 25 20 71 22 26 27 1 18 2 2 2 2 1 1 23 1 74 13 3 3 1 1 24 3 4 5 8 9 1 2 3 3 4 4 28 5 3 3 75 3 4 2 1 29 5 6 6 5 25 7 2 9 134 26 30 5 1 7 2 3 31 2 7 6 4 86 7 8 5 6 9 10 5 2 6 1...

result:

ok ok

Test #39:

score: 22
Accepted
time: 27ms
memory: 52048kb

input:

5
147
1196 1056
1 2
2 3
2 4
3 5
3 6
5 7
3 8
2 9
3 10
10 11
2 12
3 13
12 14
4 15
4 16
3 17
6 18
6 19
10 20
3 21
9 22
8 23
2 24
2 25
6 26
1 27
4 28
3 29
1 30
11 31
8 32
5 33
5 34
7 35
3 36
9 37
1 38
9 39
6 40
4 41
7 42
5 43
4 44
12 45
2 46
8 47
5 48
8 49
6 50
9 51
11 52
5 53
6 54
2 55
9 56
8 57
10 58
...

output:

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

result:

ok ok

Test #40:

score: 22
Accepted
time: 27ms
memory: 52036kb

input:

5
123
1403 768
1 2
1 3
3 4
1 5
1 6
6 7
2 8
8 9
1 10
3 11
2 12
5 13
5 14
2 15
8 16
10 17
6 18
7 19
8 20
10 21
10 22
10 23
6 24
4 25
4 26
7 27
3 28
3 29
8 30
9 31
4 32
4 33
10 34
8 35
6 36
2 37
3 38
5 39
9 40
2 41
1 42
3 43
1 44
9 45
7 46
2 47
3 48
2 49
3 50
8 51
9 52
5 53
10 54
3 55
3 56
1 57
5 58
2 ...

output:

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

result:

ok ok

Test #41:

score: 22
Accepted
time: 32ms
memory: 52116kb

input:

5
227
1768 690
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51...

output:

345
90 1 85 2 3 31 4 22 28 35 5 6 7 157 62 8 234 9 10 37 37 240 140 134 218 11 3 12 98 94 53 13 211 111 14 15 16 95 57 17 159 34 18 19 25 76 20 42 132 85 21 22 53 23 24 25 234 26 27 28 29 30 112 31 32 155 33 34 75 35 36 37 38 54 39 40 10 41 42 43 121 44 201 45 29 46 157 47 92 48 20 49 9 47 50 50 51 ...

result:

ok ok

Test #42:

score: 22
Accepted
time: 35ms
memory: 49992kb

input:

5
139
2287 2214
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
5 11
6 12
6 13
7 14
7 15
8 16
8 17
9 18
9 19
10 20
10 21
11 22
11 23
12 24
12 25
13 26
13 27
14 28
14 29
15 30
15 31
16 32
16 33
17 34
17 35
18 36
18 37
19 38
19 39
20 40
20 41
21 42
21 43
22 44
22 45
23 46
23 47
24 48
24 49
25 50
25 51
26 52
26 5...

output:

695
1 13 2 3 1 1 2 258 3 4 4 5 2 16 5 1 3 6 6 7 7 8 9 10 7 4 525 11 7 2 12 13 8 21 4 26 1 526 33 6 9 4 527 10 34 14 11 15 16 12 8 17 18 528 39 529 530 41 42 13 19 20 2 21 531 2 14 22 1 23 1 532 533 1 6 24 1 25 26 15 3 7 1 27 9 3 28 44 13 17 29 1 16 525 17 526 1 1 30 20 8 18 31 534 4 32 33 34 35 36 3...

result:

ok ok

Test #43:

score: 22
Accepted
time: 81ms
memory: 81116kb

input:

5
85
99108 97396
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
...

output:

48829
1 2 4463 3 4 5 6 4509 7 8 9 10 11 16056 406 12 8144 13 31010 14 15 25989 3915 16 173 6313 17 18 8478 19 1856 5905 20 21 20210 2176 22 23 7697 24 21501 25 12509 23745 26 4340 27 28 2077 29 30 31 32 176 33 34 4350 35 6375 12521 36 4293 318 26693 37 141 38 7177 39 40 41 42 1514 3416 43 5799 5373 ...

result:

ok ok

Test #44:

score: 22
Accepted
time: 69ms
memory: 75808kb

input:

5
221
97581 86531
1 2
1 3
1 4
4 5
5 6
1 7
4 8
4 9
7 10
2 11
2 12
2 13
9 14
10 15
13 16
4 17
12 18
10 19
16 20
17 21
6 22
18 23
8 24
17 25
22 26
16 27
22 28
8 29
8 30
11 31
21 32
23 33
19 34
9 35
25 36
10 37
1 38
7 39
38 40
38 41
6 42
35 43
36 44
20 45
20 46
16 47
22 48
21 49
43 50
17 51
17 52
39 53
...

output:

126
1 4 1 2 3 4 5 6 6 7 8 9 1 10 11 12 9 13 14 15 10 2 16 17 18 4 1 19 20 21 22 23 10 24 25 26 27 28 5 29 30 31 7 32 33 34 35 1 2 36 37 3 38 11 39 40 5 41 42 43 44 45 46 6 47 48 49 50 51 8 52 53 7 6 13 54 55 56 57 58 10 59 60 61 62 63 64 65 9 8 66 67 68 69 70 71 72 73 74 75 76 12 77 18 78 79 80 81 8...

result:

ok ok

Test #45:

score: 22
Accepted
time: 58ms
memory: 79880kb

input:

5
125
98543 89905
1 2
2 3
1 4
4 5
4 6
1 7
6 8
1 9
3 10
4 11
7 12
9 13
1 14
4 15
7 16
8 17
5 18
8 19
3 20
6 21
5 22
7 23
6 24
4 25
9 26
8 27
8 28
2 29
9 30
3 31
2 32
1 33
1 34
3 35
9 36
2 37
5 38
8 39
5 40
3 41
6 42
1 43
1 44
8 45
3 46
7 47
5 48
3 49
5 50
9 51
8 52
7 53
7 54
8 55
4 56
9 57
6 58
5 59
...

output:

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

result:

ok ok

Test #46:

score: 22
Accepted
time: 49ms
memory: 77924kb

input:

5
1256
83133 86248
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 5...

output:

31782
1 1287 2 3 4 60 19754 9974 4687 5 6 7 26331 16533 1941 10616 341 8 8754 14977 19354 9 6914 10 3005 11 12 13 14 15 3810 12081 12099 16 17 18 19 20 21 1326 1874 22 23 19621 24 25 3171 3174 1664 163 7775 8538 26 2294 27 4957 12194 28 29 30 4912 31 32 6538 8118 33 124 34 22450 35 1002 36 37 38 39 ...

result:

ok ok

Test #47:

score: 22
Accepted
time: 29ms
memory: 59164kb

input:

5
337
8058 14070
1 2
1 3
2 4
2 5
1 6
1 7
6 8
3 9
1 10
8 11
4 12
11 13
8 14
1 15
10 16
4 17
11 18
7 19
8 20
4 21
1 22
8 23
3 24
11 25
12 26
3 27
9 28
6 29
4 30
3 31
11 32
7 33
4 34
9 35
10 36
4 37
4 38
5 39
8 40
3 41
9 42
9 43
4 44
10 45
4 46
5 47
4 48
4 49
6 50
10 51
7 52
11 53
5 54
12 55
12 56
5 57...

output:

4114
1 2 3 4 5 6 7 5 8 9 10 11 12 6 13 14 15 9 16 17 18 1 19 20 21 22 23 24 25 2 1 26 2 27 28 29 30 4 31 32 33 34 1 35 1 4 36 37 8 3 38 39 3 40 41 12 13 42 43 44 45 46 2 47 48 49 50 51 52 53 54 55 56 9 57 4 58 59 60 61 62 7 14 63 64 65 19 23 24 8 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 10 82...

result:

ok ok

Test #48:

score: 22
Accepted
time: 47ms
memory: 62184kb

input:

5
443
9541 12325
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
...

output:

2862
153 1 469 2 16 332 419 1462 3 1414 4 359 595 1656 5 1089 817 6 300 1052 295 1511 7 1169 8 9 1772 371 10 154 437 208 204 462 11 1497 95 12 286 36 72 13 14 15 1529 508 16 1328 217 17 513 588 127 18 19 20 21 1761 1208 22 606 23 24 458 25 383 26 27 310 210 182 335 28 487 1127 11 29 30 31 138 91 216...

result:

ok ok

Subtask #6:

score: 32
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Dependency #5:

100%
Accepted

Test #49:

score: 32
Accepted
time: 233ms
memory: 165264kb

input:

6
178
497927 412086
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 ...

output:

120
66 8 19 34 42 1 9 1 25 7 2 3 4 5 80 30 6 7 8 9 15 10 29 11 22 12 2 13 63 14 15 5 16 17 86 18 3 26 9 19 20 12 27 24 21 29 82 22 34 23 79 24 15 25 26 27 28 15 29 30 71 110 7 31 32 33 34 39 5 35 36 37 38 27 39 40 6 41 42 24 5 54 36 45 35 43 44 26 45 32 51 46 47 16 32 79 7 48 49 50 2 51 16 39 28 52 ...

result:

ok ok

Test #50:

score: 32
Accepted
time: 329ms
memory: 158672kb

input:

6
3234
454553 464302
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50...

output:

232572
11515 1 2 10771 62301 3 66701 4 5 44349 56404 92776 11880 5814 6 56644 7 8 9 10 11 14709 12 21370 629 13 62847 88988 14 15 16 17 56757 23661 18 217723 19 20 21 16744 12933 22 23 69448 24 74029 25 26 27 13564 43367 110988 8518 44958 28 29 157253 30 9906 31 17246 19825 32 33 34 35 63862 36 37 1...

result:

ok ok

Test #51:

score: 32
Accepted
time: 572ms
memory: 145560kb

input:

6
5593
417535 438611
1 2
1 3
1 4
1 5
1 6
1 7
4 8
2 9
1 10
8 11
9 12
12 13
10 14
11 15
14 16
15 17
7 18
6 19
19 20
3 21
20 22
22 23
23 24
16 25
24 26
26 27
25 28
18 29
13 30
27 31
21 32
5 33
30 34
31 35
32 36
34 37
17 38
33 39
38 40
40 41
28 42
36 43
42 44
29 45
37 46
43 47
44 48
35 49
47 50
39 51
50...

output:

347915
1 2 3 4 5 6 7 3221 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 84 27 28 29 30 31 32 33 2717 34 565 35 36 37 38 39 40 41 42 915 43 44 45 628 46 1022 47 48 49 50 51 951 52 53 54 55 56 57 58 59 60 61 62 3739 63 64 1436 1148 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 2726...

result:

ok ok

Test #52:

score: 32
Accepted
time: 306ms
memory: 99800kb

input:

6
13826
84978 124376
1 2
2 3
3 4
4 5
3 6
1 7
4 8
8 9
7 10
7 11
3 12
5 13
12 14
10 15
6 16
14 17
9 18
15 19
8 20
13 21
12 22
20 23
16 24
23 25
4 26
5 27
2 28
5 29
5 30
17 31
5 32
24 33
11 34
14 35
11 36
25 37
22 38
16 39
11 40
29 41
38 42
17 43
38 44
41 45
17 46
44 47
33 48
42 49
6 50
29 51
51 52
3 5...

output:

80099
2 1 2 3 4 5 6 7 8 1 9 10 11 12 13 2 14 2 15 3 16 17 18 19 20 21 6 22 23 24 7 25 26 27 28 1 29 30 31 37 32 33 9 34 35 36 37 1 38 39 1 40 41 42 43 44 45 46 2 47 48 49 50 17 1 51 52 53 54 18 55 56 57 58 59 60 61 62 63 64 65 10 66 67 16 68 69 20 70 29 71 72 73 74 22 75 24 76 4 1 77 78 14 79 80 3 4...

result:

ok ok

Test #53:

score: 32
Accepted
time: 301ms
memory: 111500kb

input:

6
3480
135245 82221
1 2
1 3
1 4
1 5
1 6
4 7
3 8
5 9
2 10
6 11
1 12
11 13
13 14
14 15
8 16
10 17
12 18
16 19
7 20
19 21
18 22
20 23
15 24
23 25
24 26
26 27
17 28
22 29
29 30
9 31
31 32
21 33
33 34
25 35
30 36
27 37
37 38
38 39
39 40
36 41
40 42
35 43
34 44
42 45
32 46
43 47
47 48
44 49
45 50
28 51
50...

output:

8376
1 2 3 1693 3632 1824 4475 241 2124 175 2891 4923 2215 173 4 324 5986 5762 1571 2752 3244 1474 3077 4005 198 466 1389 10 5 390 3684 533 1675 4323 13 497 530 6 591 4549 7 8 544 2591 9 2474 303 2750 578 2541 714 3227 3072 10 5852 1977 5775 8006 2303 8282 2880 1502 464 6978 352 360 5470 8138 814 26...

result:

ok ok

Test #54:

score: 32
Accepted
time: 192ms
memory: 95560kb

input:

6
6213
156426 135199
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50...

output:

62086
1 2 3 11381 15434 4 5 6 7 14829 8 9 308 10 212 4141 11165 11 3144 12 1451 2992 13 19025 14 15 28937 2457 16 17 12264 1267 18 19 53060 1102 17749 20 21 27609 22 2061 27670 4108 4612 23 9520 24 25 26 25331 27 14761 28 694 29 16440 21080 30 31 26777 32 33 28069 6828 34 35 36 3315 23079 240 529 37...

result:

ok ok

Test #55:

score: 32
Accepted
time: 130ms
memory: 52752kb

input:

6
394
1424 1766
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
5 11
6 12
6 13
7 14
7 15
8 16
8 17
9 18
9 19
10 20
10 21
11 22
11 23
12 24
12 25
13 26
13 27
14 28
14 29
15 30
15 31
16 32
16 33
17 34
17 35
18 36
18 37
19 38
19 39
20 40
20 41
21 42
21 43
22 44
22 45
23 46
23 47
24 48
24 49
25 50
25 51
26 52
26 5...

output:

604
1 2 3 4 1 1 5 1 8 6 6 2 7 8 8 9 9 10 11 10 11 12 13 4 14 2 15 12 16 3 17 18 19 13 20 3 21 2 4 3 5 22 7 14 15 16 23 17 18 7 4 1 1 19 2 7 20 21 24 25 320 26 27 28 22 23 5 6 29 30 31 32 9 33 24 34 10 35 25 36 7 37 38 26 3 27 28 2 443 39 9 40 41 42 43 44 29 1 45 46 30 47 48 1 3 31 32 443 49 50 51 1 ...

result:

ok ok

Test #56:

score: 32
Accepted
time: 133ms
memory: 54716kb

input:

6
400
1210 2471
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
5 11
6 12
6 13
7 14
7 15
8 16
8 17
9 18
9 19
10 20
10 21
11 22
11 23
12 24
12 25
13 26
13 27
14 28
14 29
15 30
15 31
16 32
16 33
17 34
17 35
18 36
18 37
19 38
19 39
20 40
20 41
21 42
21 43
22 44
22 45
23 46
23 47
24 48
24 49
25 50
25 51
26 52
26 5...

output:

1521
1 2 3 5 4 5 6 7 10 8 9 4 2 10 11 12 13 14 15 6 9 16 17 18 19 11 20 11 3 6 5 21 22 23 1 16 18 1 24 25 15 26 27 20 28 29 32 30 3 31 17 32 33 34 35 36 12 37 2 5 38 39 40 22 4 1 41 42 14 43 24 7 1 34 44 9 45 42 46 18 47 48 49 44 6 50 51 1 55 52 53 1 1 28 54 30 55 56 57 58 59 35 3 3 60 1 10 61 37 62...

result:

ok ok

Test #57:

score: 32
Accepted
time: 136ms
memory: 52848kb

input:

6
428
1031 1178
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
5 11
6 12
6 13
7 14
7 15
8 16
8 17
9 18
9 19
10 20
10 21
11 22
11 23
12 24
12 25
13 26
13 27
14 28
14 29
15 30
15 31
16 32
16 33
17 34
17 35
18 36
18 37
19 38
19 39
20 40
20 41
21 42
21 43
22 44
22 45
23 46
23 47
24 48
24 49
25 50
25 51
26 52
26 5...

output:

747
1 2 3 8 4 5 6 7 8 6 9 10 9 16 10 11 12 13 21 7 14 11 30 15 34 16 17 18 19 35 20 21 22 23 36 7 1 42 24 25 26 27 28 2 3 29 30 1 31 8 32 33 34 11 35 36 6 37 60 4 38 2 39 40 62 3 4 41 42 43 44 45 1 63 46 47 14 48 49 50 17 17 51 52 53 54 55 18 24 56 1 57 25 1 58 59 70 1 60 14 61 62 77 63 64 3 26 82 6...

result:

ok ok

Test #58:

score: 32
Accepted
time: 141ms
memory: 52748kb

input:

6
433
1412 1032
1 2
1 3
3 4
3 5
5 6
6 7
3 8
3 9
3 10
6 11
3 12
3 13
6 14
4 15
4 16
2 17
6 18
2 19
1 20
1 21
2 22
5 23
4 24
3 25
2 26
4 27
1 28
5 29
1 30
6 31
1 32
4 33
3 34
4 35
3 36
4 37
4 38
3 39
6 40
1 41
1 42
4 43
1 44
2 45
3 46
3 47
5 48
6 49
5 50
4 51
4 52
3 53
3 54
1 55
2 56
2 57
3 58
3 59
2 ...

output:

344
4 1 2 1 3 4 5 6 7 5 8 7 9 10 11 8 6 12 13 14 15 11 16 4 17 18 16 19 20 21 10 22 23 24 25 26 27 17 28 29 30 31 32 33 34 35 36 37 21 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 5 55 56 57 58 12 59 60 24 61 62 63 64 65 66 67 1 16 25 68 69 70 71 2 72 73 74 18 27 75 76 77 78 79 80 81 82 19 83 ...

result:

ok ok

Test #59:

score: 32
Accepted
time: 137ms
memory: 54772kb

input:

6
441
1130 2385
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
7 11
4 12
10 13
1 14
13 15
2 16
12 17
14 18
3 19
19 20
6 21
17 22
11 23
9 24
15 25
16 26
20 27
8 28
21 29
5 30
26 31
27 32
18 33
23 34
22 35
35 36
31 37
33 38
37 39
24 40
40 41
30 42
25 43
41 44
28 45
29 46
44 47
45 48
38 49
47 50
36 51
34 52
48 5...

output:

730
1 2 11 2 3 4 5 6 7 8 139 1 1 9 5 10 11 9 47 12 51 13 2 22 5 31 106 14 15 7 16 103 112 49 378 50 8 158 17 18 113 14 19 20 21 5 94 24 22 36 11 23 37 24 14 23 10 149 146 13 20 113 3 50 37 55 8 25 26 3 379 85 27 28 73 11 62 29 106 3 245 30 119 38 14 31 89 16 77 20 23 84 2 37 4 90 32 35 39 1 33 18 34...

result:

ok ok

Test #60:

score: 32
Accepted
time: 321ms
memory: 159924kb

input:

6
2736
454986 470122
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50...

output:

204856
1 58300 2 42023 98316 3 19539 134719 519 12867 18778 4 5 6 7 8 531 9 141841 10 102486 11 12 42322 13 14 15 7035 16 17 18 14111 69290 38734 15549 13341 19 20 21 4834 22 16202 23 89902 6622 141969 95646 201167 24 42307 1100 25 118818 26 51407 27 28 29 30 145486 89736 31 156211 58715 32 4257 33 ...

result:

ok ok