import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(500005) N = int(readline()) UV = [map(int, readline().split()) for _ in range(N-1)] graph = [[] for _ in range(N)] for u, v in UV: graph[u-1].append(v-1) graph[v-1].append(u-1) res = [0 for _ in range(N)] def dfs(v, par): sz = 1 sq = 0 for u in graph[v]: if u != par: s = dfs(u, v) sz += s sq += s * s res[v] = sz * sz - sq return sz dfs(0, -1) for r in res: print(r)