Problem: You are given a tree consisting of n nodes. You want to write some labels on the tree's edges such that the following conditions hold:

  * Every label is an integer between 0 and n-2 inclusive. 
  * All the written labels are distinct. 
  * The largest value among MEX(u,v) over all pairs of nodes (u,v) is as small as possible. 



Here, MEX(u,v) denotes the smallest non-negative integer that isn't written on any edge on the unique simple path from node u to node v.

Input

The first line contains the integer n (2 ≤ n ≤ 10^5) — the number of nodes in the tree.

Each of the next n-1 lines contains two space-separated integers u and v (1 ≤ u,v ≤ n) that mean there's an edge between nodes u and v. It's guaranteed that the given graph is a tree.

Output

Output n-1 integers. The i^{th} of them will be the number written on the i^{th} edge (in the input order).

Examples

Input


3
1 2
1 3


Output


0
1


Input


6
1 2
1 3
2 4
2 5
5 6


Output


0
3
2
4
1

Note

The tree from the second sample:

<image>

Solution (in PYTHON3):

Solution:
from sys import stdin

inf=stdin
n=int(inf.readline())
arr=[0]*(n+1)
ll=[]
for qw in range(n-1):
	a,b=map(int,inf.readline().split(" "))
	ll.append([a,b])
	arr[a]+=1
	arr[b]+=1
count=0
for i in range(n+1):
	if(arr[i]==1):
		count+=1
count1=count
count-=1

if(n!=2):
	for i in range(n-1):
		a=ll[i][0]
		b=ll[i][1]
		if(arr[a]==1 or arr[b]==1):
			print(count)
			count-=1
		else:
			print(count1)
			count1+=1
else:
	print(0)




#n=int(inf.readline())
#s=inf.readline()
# s="bacabcab"
# changed=False
# while not changed:
# 	print(s)
# 	changed=True
# 	i=0
# 	ll=len(s)
# 	while(i+1<ll and ord(s[i])!=ord(s[i+1])+1):
# 		i+=1
# 	j=i+1
# 	while(j+1<ll and ord(s[j])==ord(s[j+1])+1):
# 		j+=1

# 	if(i+1!=ll):
# 		s=s[:i]+s[j+1:]
# 		changed=False
# 	print(i,j,s[:i],s[j+1:])

# 	i=0
# 	ll=len(s)
# 	while(i+1<ll and ord(s[i])!=ord(s[i+1])-1):
# 		i+=1
# 	j=i+1
# 	while(j+1<ll and ord(s[j])==ord(s[j+1])-1):
# 		j+=1
# 	if(i+1!=ll):
# 		s=s[:i+1]+s[j+2:]
# 		changed=False
# 	print(i,j,s[:i+1],s[j+2:])

# print(len(s))
# for i in dicti:
# 	temp=0
# 	for j in helper:
# 		if(j[0]<=i[0] and j[1]<=i[1]):
# 			temp+=(i[0]-j[0]+1)*(i[1]-j[1]+1)
# 		if(j[1]<=i[0] and j[0]<=i[1] and j[0]!=j[1]):
# 			temp+=(i[0]-j[1]+1)*(i[1]-j[0]+1)
# 	count+=temp*dicti[i]



# def all_partitions(string):
#     for cutpoints in range(1 << (len(string)-1)):
#         result = []
#         lastcut = 0
#         for i in range(len(string)-1):
#             if (1<<i) & cutpoints != 0:
#                 result.append(string[lastcut:(i+1)])
#                 lastcut = i+1
#         result.append(string[lastcut:])
#         yield result

# maxyet=0
# store={'h': -6, 'e': -7, 'l': -8, 'o': 3, 'he': 3, 'hel': -3, 'el': 0, 'hell': 6, 'ell': -5, 'll': 10, 'hello': -3, 'ello': -8, 'llo': 9, 'lo': -6}

# def quality(stri):
# 	return store[stri]

# for partition in all_partitions("hel"):
#     temp=0
#     for i in partition:
#     	temp+=quality(i)
#     if(temp>maxyet):
#     	print(partition)
#     	maxyet=temp

# print(maxyet)