n = int(input()) edges = [sorted(list(map(int, input().split())), reverse=True) for _ in range(n - 1)] edges.sort() cnt = [0] * n for a, b in edges: a -= 1; b -= 1 cnt[a] = cnt[b] + 1 print(*cnt, sep="\n")