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>
import sys
input=sys.stdin.readline
n=int(input())
d={}
dc={}
for i in range(n-1):
    a,b=map(int,input().split())
    dc[(a,b)]=-1
    if(a not in d):
        d[a]=[]
    if(b not in d):    
        d[b]=[]
    d[a].append(b)
    d[b].append(a)
ct=0
b=False    
for i in d.keys():
    if(len(d[i])>2):
        for j in d[i]:       
            if((i,j) in dc and dc[(i,j)]==-1):
                dc[(i,j)]=ct
                ct+=1
            elif((j,i) in dc and dc[(j,i)]==-1):
                dc[(j,i)]=ct
                ct+=1
            b=True
            if(ct==3):
                break
    if(b==True):
        break
if(b==True):
    val=3
    for i in dc.keys():
        if(dc[i])==-1:
            dc[i]=val
            val+=1
    for i in dc.keys():
        print(dc[i])
else:
    lt=[]
    for i in d.keys():
        if(len(d[i])==1):
            lt.append(i)
    a=lt[0]
    b=lt[1]
    if((a,d[a][0]) in dc):
        dc[(a,d[a][0])]=0
    else:
        dc[(d[a][0],a)]=0
    if((b,d[b][0]) in dc):
        dc[(b,d[b][0])]=1
    else:
        dc[(d[b][0],b)]=1
    val=2
    for i in dc.keys():
        if(dc[i])==-1:
            dc[i]=val
            val+=1
    if(n==2):
        print("0")
    else:
        for i in dc.keys():
            print(dc[i])
        
