n = int(input())
graph = [[] for _ in range(n)]
edge = []
for _ in range(n - 1):
    a, b = map(int,input().split())
    a -= 1; b -= 1
    edge.append((a, b))
    graph[a].append(b)
    graph[b].append(a)

value = [0] * n
visit = [-1] * n
visit[0] = 0
from collections import deque
q = deque()
q.append(0)
while q:
    now = q.popleft()
    for to in graph[now]:
        if visit[to] < 0:
            visit[to] = visit[now] + 1
            q.append(to)
depth = visit
for a, b in edge:
    if a > b: a, b = b, a
    #a < bを仮定
    if depth[a] > depth[b]:
        value[a] -= 1
        value[0] += 1
    else:
        value[b] += 1
        
        
visit = [False] * n
visit[0] = True
q = deque()
q.append(0)
while q:
    now = q.pop()
    for to in graph[now]:
        if depth[to] > depth[now]:
            value[to] += value[now]
            q.append(to)

for v in value:
    print(v)