#include <bits/stdc++.h>
using namespace std;
int main() {
  int maxn = 100000 + 5;
  int n;
  cin >> n;
  vector<int> g[maxn];
  int a[maxn];
  fill(a, a + maxn, -1);
  for (int i = 1, u, v; i < n; i++) {
    cin >> u >> v;
    g[u].push_back(i);
    g[v].push_back(i);
  }
  int label = 0;
  for (int i = 1; i <= n; i++) {
    if (g[i].size() >= 3) {
      for (auto u : g[i]) {
        if (a[u] == -1) {
          a[u] = label;
          label++;
        }
      }
    }
  }
  for (int i = 1; i < n; i++) {
    if (a[i] == -1) {
      cout << label << " ";
      label++;
    } else {
      cout << a[i] << " ";
    }
  }
  cout << endl;
  return 0;
}
