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;
const long long MOD = 1e9 + 7;
const long long INF = 2e9;
const long double PI = acos((long double)-1);
const long double EPS = 1e-9;
inline bool isPrime(long long x) {
  if (x <= 1) return 0;
  if (x <= 3) return 1;
  if (!(x % 2) || !(x % 3)) return 0;
  long long s = sqrt(1.0 * x) + EPS;
  for (long long i = 5; i <= s; i += 6) {
    if (!(x % i) || !(x % (i + 2))) return 0;
  }
  return 1;
}
inline long long fpow(long long n, long long k, long long p = 2e18) {
  long long r = 1;
  for (; k; k >>= 1) {
    if (k & 1) r = r * n % p;
    n = n * n % p;
  }
  return r;
}
inline int inv(int a, long long p = 2e18) { return fpow(a, p - 2, p); }
inline void addmod(int& a, int val, int p = MOD) {
  if ((a = (a + val)) >= p) a -= p;
}
inline void submod(int& a, int val, int p = MOD) {
  if ((a = (a - val)) < 0) a += p;
}
inline long long gcd(long long a, long long b) {
  long long r;
  while (b) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
inline long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
const int N = 3e5 + 5;
long long n, m;
long long a[N];
vector<int> adj[N];
void Solve() {
  cin >> n;
  vector<pair<int, int> > edges;
  map<pair<int, int>, int> mp;
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
    edges.push_back({u, v});
  }
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (int((adj[i]).size()) == 1 && !mp.count({i, adj[i][0]})) {
      mp[{i, adj[i][0]}] = mp[{adj[i][0], i}] = cnt++;
    }
  }
  for (auto p : edges) {
    int u = p.first;
    int v = p.second;
    if (mp.count({u, v})) {
      cout << mp[{u, v}] << "\n";
    } else {
      cout << cnt++ << "\n";
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);
  int query = 1;
  int start = 1000 * clock() / CLOCKS_PER_SEC;
  while (query--) Solve();
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC - start
       << "ms\n";
}