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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class First {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        //int a = 1;
        int t;
        //t = in.nextInt();
        t = 1;
        while (t > 0) {
            //out.print("Case #"+(a++)+": ");
            solver.call(in,out);
            t--;
        }
        out.close();

    }

    static class TaskA {
        int n;
        Map<String, Integer> integerMap;
        Map<Integer, Boolean> visited;
        Map<Integer, LinkedList<Integer>> listMap;
        int value = 0;

        public void call(InputReader in, PrintWriter out) {
            n = in.nextInt();
            visited = new HashMap<>();
            listMap = new HashMap<>();
            integerMap = new HashMap<>();

            answer[] arr = new answer[n-1];

            int a, b;

            for (int i = 0; i < n-1; i++) {
                a = in.nextInt();
                b = in.nextInt();
                arr[i] = new answer(a,b);

                if(listMap.getOrDefault(a,null)==null){
                    listMap.put(a, new LinkedList<>());
                }
                listMap.get(a).add(b);

                if(listMap.getOrDefault(b,null)==null){
                    listMap.put(b, new LinkedList<>());
                }
                listMap.get(b).add(a);
            }
            if(n==2){
                out.println(0);
                return;
            }
            if(n==3){
                out.println(0);
                out.println(1);
                return;
            }

            dfs(1);

            int c = 3;

            if(integerMap.size()==0){
                c = 0;
                for (int i = 0; i < arr.length; i++) {
                    out.print(c+" ");
                    c++;
                }
            }
            else {
                for (int i = 0; i < arr.length; i++) {
                    if (integerMap.getOrDefault(arr[i].a + " " + arr[i].b, -1) == -1 && integerMap.getOrDefault(arr[i].b + " " + arr[i].a, -1) == -1) {
                        out.print(c + " ");
                        c++;
                    } else {
                        if (integerMap.getOrDefault(arr[i].a + " " + arr[i].b, -1) != -1) {
                            out.print(integerMap.get(arr[i].a + " " + arr[i].b) + " ");
                        } else {
                            out.print(integerMap.get(arr[i].b + " " + arr[i].a) + " ");
                        }
                    }
                }

            }
            out.println();
        }

        public void dfs(int a){
            visited.put(a, true);
            if(a!=1 && listMap.get(a).size()>=3 && value==0){
                for (int i = 0; i < 3; i++) {
                    int b = listMap.get(a).get(i);
                    integerMap.put(a+" "+b ,value);
                    value++;
                }
                return;
            }

            for (Integer i: listMap.get(a)) {
                if(!visited.getOrDefault(i,false)){
                    dfs(i);
                }
            }
        }

    }

    static int gcd(int a, int b)
    {
        if (a == 0)
            return b;
        return gcd(b % a, a);
    }

    static int lcm(int a, int b)
    {
        return (a / gcd(a, b)) * b;
    }

    static class answer implements Comparable<answer>{
        int a;
        int b;

        public answer(int a, int b) {
            this.a = a;
            this.b = b;
        }

        @Override
        public int compareTo(answer o) {
            return this.a - o.a;
        }
    }

    static class answer1 implements Comparable<answer1>{
        int a, b, c;

        public answer1(int a, int b, int c) {
            this.a = a;
            this.b = b;
            this.c = c;

        }

        @Override
        public int compareTo(answer1 o) {
            return this.a - o.a;
        }
    }

    static long gcd(long a, long b)
    {
        if (b == 0)
            return a;
        return gcd(b, a % b);
    }

    static void sort(long[] a) {
        ArrayList<Long> l=new ArrayList<>();
        for (long i:a) l.add(i);
        Collections.sort(l);
        for (int i=0; i<a.length; i++) a[i]=l.get(i);
    }

    static final Random random=new Random();

    static void shuffleSort(int[] a) {
        int n=a.length;
        for (int i=0; i<n; i++) {
            int oi=random.nextInt(n), temp=a[oi];
            a[oi]=a[i]; a[i]=temp;
        }
        Arrays.sort(a);
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong(){
            return Long.parseLong(next());
        }
        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }
}