import sys input = sys.stdin.readline N=int(input()) E=[[] for i in range(N)] for i in range(N-1): x,y=map(int,input().split()) x-=1 y-=1 E[x].append(y) E[y].append(x) ROOT=0 QUE=[ROOT] Parent=[-1]*N Parent[ROOT]=N # ROOTの親を定めておく. TOP_SORT=[] # トポロジカルソート Child=[[] for i in range(N)] while QUE: # トポロジカルソートと同時に親を見つける x=QUE.pop() TOP_SORT.append(x) for to in E[x]: if Parent[to]==-1: Parent[to]=x Child[x].append(to) QUE.append(to) UP=[0]*N DOWN=[0]*N # xとParent[x]をつなぐedgeを考える # UP[x]は、xをROOTとする部分木に関する値。 # xとつながるnodeのうち、Parent[x]以外をxの子と捉える。 # DOWN[x]はParent[x]をROOTとする部分木に関する値。 # Parent[x]とつながるnodeのうち、x以外をParent[x]の子と捉える。 def compose_calc(x,c,k0,k1):# 子たちの値を合成する if c