#include <bits/stdc++.h>
using namespace std;
long long int fast_pow(long long int k, long long int p) {
  if (p == 0) return 1;
  long long int P = fast_pow(k, p / 2);
  P = (P * P) % 1000000007;
  if (p % 2 == 1) P = (P * k) % 1000000007;
  return P;
}
long long int invmod(long long int a, long long int m) {
  return fast_pow(a, m - 2);
}
bool isPrime(long long int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
long long int nextPowerOf2(long long int n) {
  n >>= 1;
  long long int count = 0;
  if (n && !(n & (n - 1))) return n;
  while (n != 0) {
    n >>= 1;
    count += 1;
  }
  return 1 << count;
}
long long int binomialCoeff(long long int n, long long int k) {
  long long int C[k + 1];
  memset(C, 0, sizeof(C));
  C[0] = 1;
  for (long long int i = 1; i <= n; i++) {
    for (long long int j = min(i, k); j > 0; j--) C[j] = C[j] + C[j - 1];
  }
  return C[k];
}
int main() {
  int n;
  cin >> n;
  int c = 0;
  int f = 0;
  map<int, int> m;
  for (int i = 0; i < n - 1; i++) {
    int u1, v1;
    cin >> u1 >> v1;
    f++;
    if (i == n - 2) {
      cout << 1 << endl;
    } else {
      cout << c << endl;
      if (c == 0) {
        if (c + 2 <= n - 2)
          c = c + 2;
        else
          c++;
      } else
        c++;
    }
  }
}
