#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-Ofast")
using namespace std;
const long long MAX = 2e5 + 5;
const long long MAX2 = 2e5 + 4;
const long long MAAX = 2e18;
const long long MOD = 1e9 + 7;
long long n;
long long vis[MAX];
long long ans[MAX];
pair<long long, long long> p[MAX];
long long main() {
  cin >> n;
  for (long long i = 0; i < n - 1; i++) {
    cin >> p[i].first >> p[i].second;
  }
  for (long long i = 0; i < n - 1; i++) {
    cout << i << endl;
  }
  return 0;
}
