n = int(input())
nodes = []

for i in range(n-1):
	a = [int(j) for j in input().split()]
	nodes.append(a)

li = sorted(nodes, key=lambda l:l[0], reverse=True)
li = sorted(li, key=lambda l:l[1], reverse=True)
# print(li)

ans = []
for i in nodes:
	ans.append(li.index(i))
for i in ans:
	print(i)