N u_1 v_1 u_2 v_2 ... u_(N-1) v_(N-1) (1 ≤ u_i, v_i ≤ N)
N = int(sys.stdin.readline())
tree = [set() for _ in range(N)]
for _ in range(N - 1):
u, v = [int(x) for x in sys.stdin.readline().split()]
tree[u - 1].add(v - 1)
tree[v - 1].add(u - 1)
from teflib import tree as ttree
...
N = int(sys.stdin.readline())
tree = ttree.create_tree_from_input(N)
==== 이진 트리에서