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.io.*;
import java.util.*;

public class Equal {
    static class pair implements Comparable<pair> {
        int x;
        int keema;

        public pair(int xx, int modd) {
            x = xx;
            keema = modd;
        }

        public int compareTo(pair o) {
            if (keema < o.keema)
                return 1;
            if (keema > o.keema)
                return -1;
            return 0;
        }

        @Override
        public boolean equals(Object obj) {
            return x==((pair)obj).x&&keema==((pair)obj).keema;
        }
    }

//    static long mem[][][];
//    static long in[][];
//    static int N, K;
//
//    static long dp(int i, int j, int p) {
//        if (i >= N)
//            return 0;
//        if (j >= K)
//            return 0;
//        if (p <= 0)
//            return 0;
//        if (mem[i][j][p] != -1)
//            return mem[i][j][p];
//        return mem[i][j][p] = Math.max(in[i][j] + dp(i, j + 1, p - 1), Math.max(dp(i + 1, 0, p), in[i][j] + dp(i + 1, 0, p - 1)));
//    }
   static boolean[]vis;

    static HashSet<String>hs;
    static ArrayList<Integer>[]tree;

    static pair[]in;
    static int[]ans;
    static void dfs(int u){
        vis[u]=true;

        for (int i = 0; i <tree[u].size() ; i++) {
            if(!vis[tree[u].get(i)]){
               hs.add(""+u+" "+tree[u].get(i));
               hs.add(tree[u].get(i)+" "+u);
                dfs(tree[u].get(i));
                break;
            }
        }
    }


    public static void main(String[] args) throws IOException {
        //BufferedReader br=new BufferedReader(new FileReader("input.txt"));
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        PrintWriter out = new PrintWriter(System.out);
        int n=Integer.parseInt(br.readLine());
        tree=new ArrayList[n];
        in=new pair[n-1];
        vis=new boolean[n];
        ans=new int[n-1];
        hs=new HashSet<>();
        Arrays.fill(ans,-1);
        for (int i = 0; i <tree.length ; i++) {
            tree[i]=new ArrayList<>();
        }
        for (int i = 0; i <n-1 ; i++) {
            st=new StringTokenizer(br.readLine());
            int u=Integer.parseInt(st.nextToken())-1;
            int v=Integer.parseInt(st.nextToken())-1;
            in[i]=new pair(u,v);
            tree[u].add(v);
            tree[v].add(u);
        }
        int max=0;

        max=0;
        for (int i = 0; i <tree.length ; i++) {
            if(tree[i].size()>=3){
                for (int j = 0; j <in.length ; j++) {
                    if(in[j].keema==i||in[j].x==i)
                        ans[j]=max++;
                }
                break;
            }
        }
        for (int i = 0; i < ans.length; i++) {
            if(ans[i]==-1)
                ans[i]=max++;
        }
        for (int i = 0; i <ans.length ; i++) {
            out.println(ans[i]);
        }


        out.flush();
        out.close();

    }
}