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>
using namespace std;
long long powerFunction(long long x, long long y) {
  long long res = 1;
  long long p = 1000000007;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
bool prime[10000001];
long long P = 1000000007 - 2;
long long fact[10000001] = {0};
void sieveFunction(long long maxLimit) {
  memset(prime, true, sizeof(prime));
  prime[0] = prime[1] = false;
  for (long long i = 2; maxLimit >= i; i++) {
    if (prime[i]) {
      for (long long j = 2 * i; maxLimit >= j; j += i) prime[j] = false;
    }
  }
}
void factorialFunction(long long maxLimit) {
  fact[0] = 1;
  for (long long i = 1; i <= maxLimit; i++)
    fact[i] = (fact[i - 1] * i) % 1000000007;
  return;
}
long long nCr(long long n, long long r) {
  long long a = fact[n];
  long long b = powerFunction(fact[n - r], 1000000007 - 2);
  long long c = powerFunction(fact[r], 1000000007 - 2);
  return (a * (b % 1000000007 * c % 1000000007) % 1000000007) % 1000000007;
}
signed main() {
  long long n;
  cin >> n;
  vector<pair<long long, long long>> adj[n + 1];
  long long vis[n + 1];
  long long ind;
  long long f;
  for (long long i = 0; i < n - 1; i++) {
    vis[i] = -1;
    long long u, v;
    cin >> u >> v;
    adj[u].push_back({i, v});
    adj[v].push_back({i, u});
  }
  long long p = 0;
  for (long long i = 1; i < n + 1; i++) {
    if ((long long)adj[i].size() < 3)
      continue;
    else {
      for (auto it : adj[i]) {
        if (vis[it.first] == -1) {
          vis[it.first] = p;
          p++;
        }
      }
    }
  }
  for (long long i = 0; i < n - 1; i++) {
    if (vis[i] == -1) {
      vis[i] = p;
      p++;
    }
    cout << vis[i] << "\n";
  }
}