import sys sys.setrecursionlimit(10 ** 9) int1 = lambda x: int(x) - 1 N = int(input()) T = [[] for _ in range(N)] for _ in range(N - 1): v, w = map(int1, input().split()) T[v].append(w) T[w].append(v) ans = [1] * N def rec(child, parent): if len(T[child]) <= 1 and parent >= 0: return 1 children = [] for c in T[child]: if c != parent: children.append(rec(c, child)) S = sum(children) ans[child] = (S + 1) ** 2 - sum(x ** 2 for x in children) return S + 1 rec(0, -1) print(*ans, sep='\n')