#include <bits/stdc++.h>
using namespace std;
int c[3001][3000], res[3001];
int main() {
  int n, i, j;
  cin >> n;
  for (i = 1; i <= n; i++) c[i][0] = 0;
  int k, l, f;
  for (i = 1; i <= n; i++) {
    cin >> k >> l;
    c[k][0]++;
    c[l][0]++;
    c[k][c[k][0]] = l;
    c[l][c[l][0]] = k;
  }
  f = 1;
  while (f) {
    f = 0;
    for (i = 1; i <= n; i++) {
      if (c[i][0] == 1) {
        f = 1;
        c[i][0] = 0;
        j = 1;
        while (c[c[i][1]][j] != i) j++;
        for (; j < c[c[i][1]][0]; j++) c[c[i][1]][j] = c[c[i][1]][j + 1];
        c[c[i][1]][0]--;
      }
    }
  }
  for (i = 1; i <= n; i++)
    if (c[i][0] != 0) res[i] = 0;
  f = 1;
  while (f) {
    f = 0;
    for (i = 1; i <= n; i++) {
      if (c[i][0] == 0) {
        if (c[c[i][1]][0] != 0) {
          f = 1;
          res[i] = res[c[i][1]] + 1;
          c[i][0] = 1;
        }
      }
    }
  }
  for (i = 1; i <= n; i++) cout << res[i] << " ";
  return 0;
}
