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 CPP):

Solution:
#include <bits/stdc++.h>
int N;
std::vector<std::vector<int>> tree;
bool placed = false;
int ctr = 0;
std::vector<int> p_num, par;
std::map<std::pair<int, int>, int> e_idx;
void place_zero(int n, int p) {
  par[n] = p;
  if (tree[n].size() > 2 && !placed) {
    placed = true;
    if (n == 0) {
      p_num[tree[0][0]] = 0;
      p_num[tree[0][1]] = 1;
      p_num[tree[0][2]] = 2;
    } else {
      p_num[n] = 0;
      int ch_placed = 0;
      for (int i = 0; i < tree[n].size() || ch_placed < 2; i++) {
        if (tree[n][i] == p) continue;
        p_num[tree[n][i]] = ch_placed + 1;
        ch_placed++;
      }
    }
    ctr = 3;
  }
  for (int ch : tree[n])
    if (ch != p) place_zero(ch, n);
}
void place_normal(int n, int p) {
  if (n != 0 && p_num[n] == -1) p_num[n] = ctr++;
  for (int ch : tree[n])
    if (ch != p) place_normal(ch, n);
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  std::cin >> N;
  tree.resize(N);
  par.resize(N);
  p_num.resize(N, -1);
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    std::cin >> a >> b;
    a--;
    b--;
    tree[a].push_back(b);
    tree[b].push_back(a);
    e_idx[{a, b}] = i;
    e_idx[{b, a}] = i;
  }
  int root = -1;
  for (int i = 0; i < N; i++)
    if (tree[i].size() > 2) {
      root = i;
      break;
    }
  if (root == -1) {
    for (int i = 0; i < N; i++)
      if (tree[i].size() == 1) {
        root = i;
        break;
      }
  }
  std::vector<int> res(N - 1);
  std::queue<std::pair<int, int>> Q;
  Q.push({root, -1});
  while (!Q.empty()) {
    std::pair<int, int> cur = Q.front();
    Q.pop();
    int n = cur.first;
    int p = cur.second;
    for (int ch : tree[n])
      if (ch != p) {
        res[e_idx[{n, ch}]] = ctr++;
        Q.push({ch, n});
      }
  }
  for (int i = 0; i < N - 1; i++) std::cout << res[i] << "\n";
}