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>
#include <bits/stdc++.h>
template <class T>
T Min(T _a, T _b) {
  return _a < _b ? _a : _b;
}
template <class T>
T Max(T _a, T _b) {
  return _a > _b ? _a : _b;
}
template <class T>
T chk_Min(T &_a, T _b) {
  return _a = (_a < _b ? _a : _b);
}
template <class T>
T chk_Max(T &_a, T _b) {
  return _a = (_a > _b ? _a : _b);
}
const int N = 1e5 + 1e4;
struct edge {
  int to, next, val;
} e[N << 1];
int ehead[N], ecnt;
inline void add_edge(int now, int to, int val) {
  ecnt++;
  e[ecnt].to = to;
  e[ecnt].next = ehead[now];
  e[ecnt].val = val;
  ehead[now] = ecnt;
}
struct node {
  long long val;
  int id;
} max[N];
bool cmp(node _a, node _b) { return _a.val < _b.val; }
int n, x, y;
int son[N], val[N];
void dfs(int now, int la) {
  son[now] = 1;
  for (int i = ehead[now]; i; i = e[i].next) {
    if (e[i].to == la) continue;
    dfs(e[i].to, now);
    son[now] += son[e[i].to];
    max[e[i].val].val = (1LL * son[e[i].to] * (n - son[e[i].to]));
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1, u, v; i < n; i++) {
    max[i].id = i;
    scanf("%d%d", &u, &v);
    add_edge(u, v, i);
    add_edge(v, u, i);
  }
  dfs(1, 0);
  std::sort(max + 1, max + n, cmp);
  for (int i = 1; i < n; i++) {
    val[max[i].id] = i - 1;
  }
  for (int i = 1; i < n; i++) {
    printf("%d\n", val[i]);
  }
}
