#include <bits/stdc++.h>
using namespace std;
const long long int MAX_N = 1e5 + 7, delta = 10343;
int32_t main() {
  long long int n;
  cin >> n;
  for (long long int i = 1; i < n; i++) {
    long long int a, b;
    cin >> a >> b;
  }
  for (long long int i = 0; i < n; i++) cout << i << endl;
  return 0;
}
