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 JAVA):

Solution:
import java.util.*;
import java.io.*;

public class C1325 {
	
	static int n;
	static TreeSet<Integer>[] adjList;
	static boolean[] vis;
	static int counter;
	static TreeMap<Pair, Integer> map;
	
	/*public static int dfs(int u) {
		vis[u] = true;
		for(int v : adjList[u]) {
			if(!vis[v]) {
				int x = dfs(v);
				int min = Math.min(u, v), max = Math.max(u, v);
				map.put(new Pair(min, max), x);
			}
		}
		return ++counter;
	}*/

	public static void main(String[] args) throws IOException {
		//Scanner sc = new Scanner(System.in);
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		StringTokenizer st;
		
		n = Integer.parseInt(br.readLine());
		adjList = new TreeSet[n];
		for(int i = 0; i < n; i++)
			adjList[i] = new TreeSet<Integer>();
		int[][] store = new int[n - 1][2];
		for(int i = 0; i < n - 1; i++) {
			st = new StringTokenizer(br.readLine());
			int u = Integer.parseInt(st.nextToken()) - 1, v = Integer.parseInt(st.nextToken()) - 1;
			adjList[u].add(v);
			adjList[v].add(u);
			store[i][0] = u;
			store[i][1] = v;
		}
		
		if(n == 2) {
			pw.println("0");
			pw.flush();
			return;
		}
		
		Queue<Integer> qu = new LinkedList<>();
		for(int i = 0; i < n; i++)
			if(adjList[i].size() == 1)
				qu.add(i);
		counter = 0;
		map = new TreeMap<>();
		while(qu.size() > 1) {
			int x = qu.poll();
			int y = adjList[x].pollFirst();
			adjList[y].remove(x);
			int min = Math.min(x, y), max = Math.max(x, y);
			map.put(new Pair(min, max), counter);
			counter++;
			if(adjList[y].size() == 1)
				qu.add(y);
		}
		/*
		int maxV = 0, x = 0;
		for(int i = 0; i < n; i++)
			if(adjList[x].size() > maxV) {
				maxV = adjList[x].size();
				x = i;
			}
		
		vis = new boolean[n];
		counter = n - 1;
		dfs(x);
		*/
		
		for(int i = 0; i < n - 1; i++) {
			int min = Math.min(store[i][0], store[i][1]), max = Math.max(store[i][0], store[i][1]);
			pw.println(map.get(new Pair(min, max)));
		}
		
		pw.flush();
	}
	
	public static class Pair implements Comparable<Pair> {
		int i, j;
		
		public Pair(int i, int j) {
			this.i = i;
			this.j = j;
		}
		
		public int compareTo(Pair p) {
			if(this.j == p.j)
				return this.i - p.i;
			return this.j - p.j;
		}
	}
}