from functools import lru_cache from collections import deque N=int(input()) E={i:[] for i in range(1,N+1)} for _ in range(N-1): u,v=map(int,input().split()) E[u].append(v) E[v].append(u) T=[None]*(N+1) U=[False]*(N+1) D=[-1]*(N+1) Q=deque() T[1]=0 D[1]=0 Q.append(1) while Q: v=Q.popleft() F=True for u in E[v]: if T[u]==None: Q.append(u) D[u]=D[v]+1 T[u]=1 F=False if F: U[v]=True @lru_cache(maxsize=2*10**5) def f(N): if U[N]: return 1 else: T=1 for v in E[N]: if D[v]>D[N]: T+=f(v) return T def h(L): S=0 for p in L: S+=p*p T=sum(L) return T*T-S @lru_cache(maxsize=2*10**5) def g(N): if U[N]: return 1 else: C=[] for v in E[N]: if D[v]>D[N]: C.append(f(v)) return h(C)+2*sum(C)+1 Z=[0]*(N+1) for i in range(2,N+1): Z[i]=g(i) Z[1]=N*N-sum(Z[2:]) for i in range(1,N+1): print(Z[i])