from sys import stdin n, *indata = map(int, stdin.read().split()) g = [[] for i in range(n+1)] offset = 0 for i in range(n-1): s, t = indata[offset + 2*i],indata[offset + 2*i+1] g[s].append(t) g[t].append(s) ans = [0 for i in range(n+1)] que = [1] check = [False for i in range(n+1)] val = 0 while que: now = que.pop() check[now] = True for i in g[now]: if not check[i]: if i < now: val += 1 que.append(i) ans[1] = val que = [1] check = [False for i in range(n+1)] while que: now = que.pop() check[now] = True for i in g[now]: if not check[i]: if i < now: ans[i] = ans[now] - 1 else: ans[i] = ans[now] + 1 que.append(i) for i in range(1,n+1): print("{}".format(ans[i]))