input = """
1 2 2 1 3 4
1 3 2 1 2 4
1 4 0 0
1 5 2 1 6 7
1 6 2 1 5 7
1 7 0 0
1 8 2 1 9 10
1 9 2 1 8 10
1 10 0 0
1 11 2 1 12 13
1 12 2 1 11 13
1 13 0 0
1 14 2 1 15 16
1 15 2 1 14 16
1 16 0 0
1 17 2 1 18 19
1 18 2 1 17 19
1 19 0 0
1 20 2 1 21 22
1 21 2 1 20 22
1 22 0 0
1 23 2 1 24 25
1 24 2 1 23 25
1 25 0 0
1 26 1 0 2
1 27 1 0 17
1 28 2 0 27 20
1 29 2 0 26 5
1 26 2 0 29 5
1 30 2 0 29 14
1 31 2 0 28 23
1 32 2 0 30 8
1 1 1 1 30
1 1 1 1 31
1 1 2 0 31 32
1 33 2 1 26 5
1 33 2 1 32 8
0
27 j
33 p
12 n_d
20 g
26 i
2 a
8 c
32 o
11 d
3 n_a
18 n_f
24 n_h
31 n
30 m
9 n_c
5 b
29 l
17 f
23 h
28 k
15 n_e
14 e
21 n_g
6 n_b
0
B+
0
B-
1
0
1
"""
output = """
{b, n_c, e, f, g, h, i, j, k, l, m, n, a}
"""

input = """
1 2 2 1 3 4
1 3 2 1 2 4
1 4 0 0
1 5 2 1 6 7
1 6 2 1 5 7
1 7 0 0
1 8 2 1 9 10
1 9 2 1 8 10
1 10 0 0
1 11 2 1 12 13
1 12 2 1 11 13
1 13 0 0
1 14 2 1 15 16
1 15 2 1 14 16
1 16 0 0
1 17 2 1 18 19
1 18 2 1 17 19
1 19 0 0
1 20 2 1 21 22
1 21 2 1 20 22
1 22 0 0
1 23 2 1 24 25
1 24 2 1 23 25
1 25 0 0
1 26 1 0 2
1 27 1 0 17
1 28 2 0 27 20
1 29 2 0 26 5
1 26 2 0 29 5
1 30 2 0 29 14
1 31 2 0 28 23
1 32 2 0 30 8
1 1 1 1 30
1 1 1 1 31
1 1 2 0 31 32
1 33 2 1 26 5
1 33 2 1 32 8
0
27 j
33 p
12 n_d
20 g
26 i
2 a
8 c
32 o
11 d
3 n_a
18 n_f
24 n_h
31 n
30 m
9 n_c
5 b
29 l
17 f
23 h
28 k
15 n_e
14 e
21 n_g
6 n_b
0
B+
0
B-
1
0
1
"""
output = """
{b, n_c, e, f, g, h, i, j, k, l, m, n, a}
"""

1 2 2 1 3 4 1 3 2 1 2 4 1 4 0 0 1 5 2 1 6 7 1 6 2 1 5 7 1 7 0 0 1 8 2 1 9 10 1 9 2 1 8 10 1 10 0 0 1 11 2 1 12 13 1 12 2 1 11 13 1 13 0 0 1 14 2 1 15 16 1 15 2 1 14 16 1 16 0 0 1 17 2 1 18 19 1 18 2 1 17 19 1 19 0 0 1 20 2 1 21 22 1 21 2 1 20 22 1 22 0 0 1 23 2 1 24 25 1 24 2 1 23 25 1 25 0 0 1 26 1 0 2 1 27 1 0 17 1 28 2 0 27 20 1 29 2 0 26 5 1 26 2 0 29 5 1 30 2 0 29 14 1 31 2 0 28 23 1 32 2 0 30 8 1 1 1 1 30 1 1 1 1 31 1 1 2 0 31 32 1 33 2 1 26 5 1 33 2 1 32 8 0 27 j 33 p 12 n_d 20 g 26 i 2 a 8 c 32 o 11 d 3 n_a 18 n_f 24 n_h 31 n 30 m 9 n_c 5 b 29 l 17 f 23 h 28 k 15 n_e 14 e 21 n_g 6 n_b 0 B+ 0 B- 1 0 1 {b, n_c, e, f, g, h, i, j, k, l, m, n, a}