#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  set<long long> mex;
  for (long long i = 0; i <= n - 2; i++) {
    mex.insert(i);
  }
  for (long long i = 1; i < n; i++) {
    long long u, v;
    cin >> u >> v;
  }
  for (long long it : mex) cout << it << '\n';
}
signed main() {
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
