#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
const int maxn = 200001;
using large = int64_t;
long long gcd(long long int a, long long int b, long long &x, long long &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  long long x1, y1;
  long long d = gcd(b, a % b, x1, y1);
  x = y1;
  y = x1 - y1 * (a / b);
  return d;
}
vector<int> v[maxn];
int main() {
  int t;
  long long i, j, k, l, m, n;
  cin >> n;
  for (i = 1; i < n; i++) {
    cin >> j >> k;
    v[j].push_back(k);
    v[k].push_back(j);
  }
  for (i = 1; i < n; i++) cout << i - 1 << "\n";
}
