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:
import sys;readline = sys.stdin.readline
def i1(): return int(readline())
def nl(): return [int(s) for s in readline().split()]
def nn(n): return [int(readline()) for i in range(n)]
def nnp(n,x): return [int(readline())+x for i in range(n)]
def nmp(n,x): return (int(readline())+x for i in range(n))
def nlp(x): return [int(s)+x for s in readline().split()]
def nll(n): return [[int(s) for s in readline().split()] for i in range(n)]
def mll(n): return ([int(s) for s in readline().split()] for i in range(n))
def s1(): return readline().rstrip()
def sl(): return [s for s in readline().split()]
def sn(n): return [readline().rstrip() for i in range(n)]
def sm(n): return (readline().rstrip() for i in range(n))
def redir(s): global readline;import os;fn=sys.argv[0] + f'/../in-{s}.txt';readline = open(fn).readline if os.path.exists(fn) else readline
import os;
if 'DEPTH' in os.environ:
    def printd(*a,**aa):
        print(*a,**aa)
else:
    def printd(*a,**aa):
        pass

redir('c')
n = i1()
nodes = [[] for i in range(n)]
for i in range(n-1):
    u, v = nlp(-1)
    nodes[u].append((v,i))
    nodes[v].append((u,i))
printd(nodes)
printd([len(i) for i in nodes])
# leafs = [i for i in range(n) if len(nodes[i]) == 1]
# printd(leafs)
h3 = set()
for i in (nodes[i][0] for i in range(n) if len(nodes[i]) == 1):
    h3.add(i[1])
    if len(h3) == 3:
        break
# printd(leafs)
labels = [-1]*(n-1)
# h3 = sorted(set([i[1] for i in leafs[:3]]))  # set for test #19 one edge
printd("h3", h3)
printd("labels", labels)
for i,h in enumerate(h3):
    labels[h] = i
printd("labels", labels)
j = len(h3)
for i in range(n-1):
    if labels[i] < 0:
        labels[i] = j
        j += 1
# h3 = [0,1,3]
printd(h3)
printd(labels)
print('\n'.join(str(i) for i in labels))