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;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()
edges = [nlp(-1) for i in range(n-1)]
printd("edges", edges)
degree = [0]*n
for u,v in edges:
    degree[u] += 1
    degree[v] += 1
# leafs = [i for i in range(n) if len(nodes[i]) == 1]
# printd(leafs)
leafs = [i for i in range(n) if degree[i] == 1]
printd(leafs)
labels = list(range(n-1))
h3 = set(leafs[:3])
lst = set()
for i,(u,v) in enumerate(edges):
    if u in h3 or v in h3:
        lst.add(i)
h3 = lst
k = len(h3)
common = set(i for i in h3 if i < k)
printd("h3,common", h3,common)
for l, r in zip(set(range(k)) - common, h3 - common):
    printd("l,r", l,r)
    labels[l], labels[r] = r, l
print('\n'.join(str(i) for i in labels))
