

n = int(input())
q = n
list1 = list()
for i in range(n):
    list1.append(0)

while n-1!=0:

    a,b = map(int,input().split())
    list1[a-1]+=1



    n-=1
count = q-2

for i in range(q):
    p = list1[i]

    for j in range(p):

        print(count)
        count-=1
        if count<0:
            break

