
Map={}
n=int(input())
for _ in range(n-1):
    a,b=map(int, input().split())
    if a not in Map:
        Map[a]=[]
    Map[a].append(b)
m=(n-2)//2
ma=m+1
for i in range(n-1):
    if i%2==0:
        print(m)
        m-=1 
    else:
        print(ma)
        ma+=1

