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.awt.Point;
import java.io.*;
import java.math.BigInteger;
public class Solutions {
	 
	static FastScanner scr=new FastScanner();
	static PrintStream out=new PrintStream(System.out);
//	static ArrayList<ArrayList<Integer>>list=new ArrayList<ArrayList<Integer>>();
	public static void main(String []args) {
//		int t=scr.nextInt();
//		while(t-->0) {
			solve();
//		}
	}
	static boolean prime[]=new boolean[2000+1];
	static void solve() {
		int n=scr.nextInt();
		ArrayList<Integer>list[]=new ArrayList[n];
		for(int i=0;i<n;i++) {
			list[i]=new ArrayList<>();
		}
		for(int i=0;i<n-1;i++) {
			int u=scr.nextInt()-1;
			int v=scr.nextInt()-1;
			list[v].add(i);
			list[u].add(i);
		}
		int []label=new int[n];
		Arrays.fill(label,-1);
		boolean found=false;
		for(int i=0;i<n;i++) {
			if(list[i].size()>=3) {
				for(int j=0;j<3;j++) {
					label[list[i].get(j)]=j;
				}
				found=true;
				break;
			}
		}
		if(found) {
			int la=3;
			for(int i=0;i<n-1;i++) {
				if(label[i]==-1) {
					label[i]=la++;
				}
			}
		}else {
			for(int i=0;i<n-1;i++) {
				if(label[i]==-1) {
					label[i]=i;
				}
			}
		}
		for(int i=0;i<n-1;i++) {
			out.println(label[i]+" ");
		}
	}
	static void fill() {
		Arrays.fill(prime,true);
		prime[0]=false;
		prime[1]=false;
		for(int i=2;i<=20000;i++) {
			for(int j=2*i;j<=2000;j+=i) {
				prime[j]=false;
			}
		}
	}
	static void swap(int a[],int i,int j) {
		int temp=a[i];a[i]=a[j];
		a[j]=temp;
	}
	static long modPow(long base,long exp,long mod) {
		if(exp==0) {
			return 1;
		}
		if(exp%2==0) {
			long res=(modPow(base,exp/2,mod));
			return (res*res)%mod;
		}
		return (base*modPow(base,exp-1,mod))%mod;
	}
	static long parse(String s) {
		return Long.parseLong(s);
	}
	static long gcd(long a,long b) {
		if(b==0) {
			return a;
		}
		return gcd(b,a%b);
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int[] sort(int a[]) {
			Arrays.sort(a);
			return a;
		}
		int []reverse(int a[]){
			int b[]=new int[a.length];
			int index=0;
			for(int i=a.length-1;i>=0;i--) {
				b[index]=a[i];
			}
			return b;
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long[] readLongArray(int n) {
			long  [] a=new long  [n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
	static int MAX=Integer.MAX_VALUE;
	static int MIN=Integer.MIN_VALUE;
}class triplet{
	int x;
	int y;
	int z;
	triplet(int fisrt,int second,int third){
		this.x=fisrt;
		this.y=second;
		this.z=third;
	}
}
class pair{
	int x=0;
	int y=0;
	pair(int first,int second){
		this.x=first;
		this.y=second;
	}
}