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>
const long long inf = 1000000000000000000;
using namespace std;
bool prime[1000005];
long long fact[1000005];
long long gcd(long long a, long long b) {
  if (a < b) gcd(b, a);
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
  long long x = (a / gcd(a, b)) * b;
  return x;
}
long long power(long long x, long long n, long long m = inf) {
  if (x == 0) return 0;
  if (n == 0) return 1;
  long long ans;
  if (n % 2 == 0) {
    long long smallAns = power(x, n / 2, m);
    ans = (smallAns * smallAns) % m;
  } else {
    long long smallAns = power(x, n - 1, m);
    ans = x;
    ans = (ans * smallAns) % m;
  }
  return (ans + m) % m;
}
long long modInverse(long long n, long long p) { return power(n, p - 2, p); }
long long nCr(long long n, long long r, long long p = LLONG_MAX) {
  if (n < r) return 0;
  if (r == 0) return 1;
  return (fact[n] * modInverse(fact[r], p) % p * modInverse(fact[n - r], p) %
          p) %
         p;
}
void fillFact() {
  fact[0] = 1;
  for (int i = 1; i < 1000005; i += 1) {
    fact[i] = (fact[i - 1] * i) % 1000000007;
  }
}
void fillPrime() {
  long long i, j, n = 1000001;
  for (int i = 0; i < n; i += 1) {
    prime[i] = 1;
  }
  prime[0] = 0;
  prime[1] = 0;
  for (i = 2; i * i <= n; i++) {
    if (prime[i]) {
      for (j = i * i; j <= n; j += i) {
        prime[j] = 0;
      }
    }
  }
}
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};
long long kadane(long long arr[], int n) {
  long long dp[n];
  dp[0] = arr[0];
  long long maxm = dp[0];
  for (int i = 1; i < n; i += 1) {
    if (dp[i - 1] > 0)
      dp[i] = arr[i] + dp[i - 1];
    else
      dp[i] = arr[i];
    maxm = max(maxm, dp[i]);
  }
  return maxm;
}
bool compare(pair<int, int> p1, pair<int, int> p2) {
  return p1.second < p2.second;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) {
    int n;
    cin >> n;
    vector<int> v[n + 1];
    int ans[n + 1];
    memset(ans, -1, sizeof(ans));
    for (int i = 1; i < n; i += 1) {
      int a, b;
      cin >> a >> b;
      v[a].push_back(i);
      v[b].push_back(i);
    }
    int count = 0;
    for (int i = 1; i < n + 1; i += 1) {
      if (v[i].size() >= 3) {
        for (int j = 0; j < v[i].size(); j += 1) {
          ans[v[i][j]] = count;
          count++;
        }
        break;
      }
    }
    for (int i = 1; i < n; i += 1) {
      if (ans[i] == -1) {
        ans[i] = count++;
      }
      cout << ans[i] << '\n';
    }
  }
  return 0;
}