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.awt.List;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.StringTokenizer;

public class TaskC {
	public static void main(String[] arg) {
		final FastScanner in = new FastScanner(System.in);
		final PrintWriter out = new PrintWriter(System.out);
		final int n = in.nextInt();
		int[][] a = new int[n-1][4];
		Map<Integer,ArrayList<int[]>> map = new HashMap<Integer, ArrayList<int[]>>();
		for(int i=0;i<=n;i++) {
			map.put(i, new ArrayList<int[]>());
		}
		for (int i = 0; i < n-1; i++) {
			a[i][0] = i;
			a[i][1] = in.nextInt();
			a[i][2] = in.nextInt();
			a[i][3] = -1;
			map.get(a[i][1]).add(a[i]);
			map.get(a[i][2]).add(a[i]);
		}
		
	    int [][] g = new int[n+1][2];
	    for(int i=1;i<=n;i++) {
	    	g[i][0]=i;
	    	g[i][1]=map.get(i).size();
	    }
	    
	    Arrays.sort(g, (el1, el2) -> el1[1]-el2[1]);
	    int cnt = 0;
	    for(int i=0; i<=n; i++) {
	    	int node = g[i][0];
	    	Iterator<int[]> edges =map.get(node).iterator();
	    	while(edges.hasNext()) {
	    		int[] edge = edges.next();
	    		if(edge[3]<0) {
	    			edge[3]=cnt;
	    			cnt++;
	    		}
	    	}
	    }
	    for(int i=0;i<a.length;i++) {
	    	out.printf("%d%n", a[i][3]);
	    }
		out.close();
		in.close();
	}


	private static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		FastScanner(InputStream stream) {
			try {
				br = new BufferedReader(new InputStreamReader(stream));
			} catch (Exception e) {
				e.printStackTrace();
			}
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] readIntArr(int n) {
			int[] result = new int[n];
			for (int i = 0; i < n; i++) {
				result[i] = Integer.parseInt(next());
			}
			return result;
		}

		void close() {
			try {
				br.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}

		long nextLong() {
			return Long.parseLong(next());
		}

	}

}