#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
const int maxn = 200001;
using large = int64_t;
long long gcd(long long int a, long long int b, long long &x, long long &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  long long x1, y1;
  long long d = gcd(b, a % b, x1, y1);
  x = y1;
  y = x1 - y1 * (a / b);
  return d;
}
vector<int> v[maxn];
vector<int> v1;
vector<long double> v2;
long long p = 0;
void dfs(int node, int par, int le, long double d) {
  int j = 1;
  long double x = v[node].size();
  if (x != 1 && node != 1) x = d / (x - 1);
  if (node == 1) x = d / x;
  for (int child : v[node]) {
    if (child != par) {
      j = 0;
      dfs(child, node, le + 1, x);
    }
  }
  if (j) {
    v1.push_back(le);
    v2.push_back(d);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  long long i, j, k, l, m, n;
  cin >> n;
  for (i = 1; i < n; i++) {
    cin >> j >> k;
    v[j].push_back(k);
    v[k].push_back(j);
  }
  for (i = 1; i < n - 2; i++) cout << i - 1 << "\n";
}
