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 Test {
//

//    private static int c = 1000010;
    private static int r = 1000_000_007;

    public static void main(String[] args) {
//        Scanner in = new Scanner(System.in);
        FastScanner in = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        int n = in.nextInt();

        List<Node> nodes = new ArrayList<>();
        List<Edge> edges = new ArrayList<>();

        for (int i = 0; i < n; i++) {
            nodes.add(new Node(i));
        }
        int u, v;
        for (int i = 0; i < n - 1; i++) {
            u = in.nextInt() - 1;
            v = in.nextInt() - 1;
            Edge e = new Edge(u, v, i);
            nodes.get(u).edgs.add(e);
            nodes.get(v).edgs.add(e);
            edges.add(e);
        }
        
        if (n <= 4) {
            for (int i = 0; i < n - 1; i++) {
                System.out.println(i);
            }
        } else {
            List<Node> l = new ArrayList<>();
            for (Node node : nodes) {
                if (node.edgs.size()==1) {
                    l.add(node);
                }
            }
            
            boolean[] b1 = new boolean[n - 1];

            boolean dfs = dfs(nodes, l.get(0), l.get(1), b1);
            
            
            int y = -1;
            for (int i = 0; i < n - 1; i++) {
                if (!b1[i]) {
                    y = i;
                    break;
                }
            }
            StringBuffer sb = new StringBuffer();
            if (y == -1) {
                for (int i = 0; i < n - 1; i++) {
                    sb.append(i + "\n");
                }
            } else {
                edges.get(y).x = 0;
                l.get(0).edgs.get(0).x = 1;
                l.get(1).edgs.get(0).x = 2;
                int i = 3;
                for (Edge e : edges) {
                    if (e.x == -1) {
                        e.x = i++;
                    }
                }

                Collections.sort(edges, (e1, e2) -> {
                    return e1.i - e2.i;
                });

                for (i = 0; i < edges.size(); i++) {
                    sb.append(edges.get(i).x + "\n");
                }
            }
            
            System.out.print(sb);
        }
    }

    private static boolean dfs(List<Node> nodes, Node n1, Node n2, boolean[] b1) {
        if (n1.number == n2.number) {
            return true;
        }
        for (Edge e : n1.edgs) {
            if (!b1[e.i]) {
                b1[e.i] = true;
                
                if (e.u == n1.number) {
                    boolean b = dfs(nodes, nodes.get(e.v), n2, b1);
                    if (b) {
                        return true;
                    }
                } else {
                    if (dfs(nodes, nodes.get(e.u), n2, b1)) {
                        return true;
                    }
                }
                b1[e.i] = false;
            }
        }
        return false;
    }

}

class Edge {

    int u, v, i, x;

    public Edge(int u, int v, int i) {
        this.u = u;
        this.v = v;
        this.i = i;
        this.x = -1;
    }

}

class Node {

    int number;
    List<Edge> edgs;

    public Node(int number) {
        this.number = number;
        edgs = new ArrayList<>();
    }

}

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 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 nextLong() {
        return Long.parseLong(next());
    }
}