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

public class Main {

    static ArrayList<Integer>[] a;
    static int[] ans;
    static boolean govna = false;
    static boolean[] used;
    static int cnt = 1;
    static TreeMap<point, Integer> tm = new TreeMap<>((o1, o2) -> Integer.compare(o1.a, o2.a) * 2 + Integer.compare(o1.b, o2.b));
    static int ind2 = 0;

    static boolean dfs(int v, int p) {
        used[v] = true;
        boolean j = true;
        if (v == ind2) j = false;
        for (int to : a[v]) {
            if (!used[to]) {
                if (!dfs(to, v)) j = false;
            }
        }
        if (!j && !govna) {
            ans[tm.get(new point(Math.min(p, v), Math.max(p, v)))] = 3;
            govna = true;
            return false;
        }
        if (p != -1 && v != ind2 && ans[tm.get(new point(Math.min(v, p), Math.max(v, p)))] != 1)
            ans[tm.get(new point(Math.min(v, p), Math.max(v, p)))] = cnt++;
        return j;
    }

    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner();
        int n = in.nextInt();
        used = new boolean[n];
        ans = new int[n];
        a = new ArrayList[n];
        for (int i = 0; i < n; i++) {
            a[i] = new ArrayList<>();
        }
        for (int i = 0; i < n - 1; i++) {
            int from = in.nextInt() - 1;
            int to = in.nextInt() - 1;
            a[from].add(to);
            a[to].add(from);
            tm.put(new point(Math.min(from, to), Math.max(from, to)), i);
        }
        int one = 0;
        int two = 0;
        for (int i = 0; i < n; i++) {
            if (a[i].size() == 1) one++;
            if (a[i].size() == 2) two++;
        }
        if (one == 2 && two == n - 2) {
            for (int i = 0; i < n - 1; i++) {
                in.out.println(i);
            }
        } else {
            int cnt = 1;
            for (int i = 0; i < n; i++) {
                if (a[i].size() == 1) {
                    ans[tm.get(new point(Math.min(i, a[i].get(0)), Math.max(i, a[i].get(0))))] = cnt++;
                }
            }
            for (int i = 0; i < n - 1; i++) {
                if (ans[i] == 0) {
                    in.out.println(cnt++ -1 );
                } else in.out.println(--ans[i]);
            }
        }
        in.out.close();
    }
}

class point {
    int a, b;

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


class FastScanner {
    BufferedReader br;
    StringTokenizer st = new StringTokenizer("");
    PrintWriter out;

    FastScanner() {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
    }

    FastScanner(String in, String out_) throws FileNotFoundException {
        br = new BufferedReader(new FileReader(in));
        out = new PrintWriter(out_);
    }

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

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

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