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>
using namespace std;
const int N = 1e5 + 7, INF = 1e9 + 7, mod = 1e9 + 7;
const double PI = 3.141592653589793238462643383279502884197, eps = 1e-9;
map<pair<int, int>, int> mp;
vector<int> tree[N];
int cnt;
bool dfs(int u, int p, int v) {
  if (u == v) return 1;
  for (int i : tree[u])
    if (i != p && dfs(i, u, v)) {
      if (mp[{i, u}] == -1) mp[{i, u}] = mp[{u, i}] = cnt++;
      return 1;
    }
  return 0;
}
void solve(int x, int p) {
  if (mp[{x, p}] == -1) mp[{x, p}] = mp[{p, x}] = cnt++;
  for (int i : tree[x])
    if (i != p) solve(i, x);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, u, v;
  vector<pair<int, int> > vec;
  cin >> n;
  if (n == 2) return cout << 0, 0;
  for (int i = 1; i < n; i++) {
    cin >> u >> v;
    tree[u].push_back(v);
    tree[v].push_back(u);
    mp[{u, v}] = mp[{v, u}] = -1;
    vec.push_back({u, v});
  }
  u = v = -1;
  for (int i = 1; i <= n; i++)
    if (tree[i].size() == 1 && i != u && i != v) {
      if (u == -1)
        u = i, v = tree[i][0], mp[{u, v}] = mp[{v, u}] = 0;
      else {
        v = i;
        mp[{i, tree[i][0]}] = mp[{tree[i][0], i}] = 1;
        break;
      }
    }
  cnt = 3;
  dfs(u, -1, v);
  v = cnt;
  solve(u, -1);
  for (pair<int, int> i : vec) {
    if (mp[i] == n - 1)
      cout << 2;
    else
      cout << mp[i];
    cout << '\n';
  }
  return 0;
}
