#include <bits/stdc++.h>
using namespace std;
void fast();
long long int ar[200005];
long long int n, a, b, c, d, m, k, q, mod;
vector<long long int> v;
int32_t main() {
  fast();
  long long int t = 1;
  while (t--) {
    cin >> n;
    pair<long long int, long long int> ar[200005];
    long long int one;
    long long int loc;
    map<long long int, long long int> m;
    for (long long int i = 0; i < n - 1; i++) {
      cin >> a >> b;
      ar[i] = {a, b};
      m[a]++;
      m[b]++;
      if (m[a] == 1) {
        one = a;
        loc = i;
      } else if (m[b] == 1) {
        one = b;
        loc = i;
      }
    }
    long long int ans[200005] = {0};
    long long int j = 1;
    ans[loc] = 0;
    for (long long int i = 0; i < n; i++)
      if (i != loc) ans[i] = j++;
    for (long long int i = 0; i < n - 1; i++) cout << ans[i] << " ";
    cout << "\n";
  }
  return 0;
}
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
