#include <bits/stdc++.h>
void searchd(int, int);
void dfs(int, int);
bool fing = false, bag = false;
const int nMax = 3004;
int g[nMax][nMax], circle[nMax], useds[nMax], used[nMax];
int bgv = -1;
int main() {
  int n, i, a, b;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d %d", &a, &b);
    g[a][++g[a][0]] = b;
    g[b][++g[b][0]] = a;
  }
  for (i = 1; i <= n; i++) {
    if (useds[i] == 0) {
      for (int j = 1; j <= n; j++) used[j] = 0;
      used[i] = 1;
      searchd(i, 0);
      if (fing) break;
    }
  }
  for (i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) used[j] = 0;
    if (circle[i] == 1) dfs(i, 1);
  }
  for (i = 1; i <= n; i++) printf("%d ", circle[i] - 1);
  return 0;
}
void searchd(int s, int fr) {
  if (fing) return;
  int i;
  for (i = 1; i <= g[s][0]; i++) {
    if (fr == g[s][i]) continue;
    if (used[g[s][i]] == 1) {
      bag = true;
      bgv = g[s][i];
      circle[g[s][i]] = 1;
      return;
    } else {
      used[g[s][i]] = 1;
      searchd(g[s][i], s);
      if (bgv > 0) circle[g[s][i]] = 1;
      if (bgv == s) {
        fing = true;
        bgv = 0;
      }
      if (fing) return;
      used[g[s][i]] = 0;
    }
    if (bag) break;
  }
  used[s] = 0;
  return;
}
void dfs(int s, int dl) {
  int i;
  for (i = 1; i <= g[s][0]; i++) {
    if (circle[g[s][i]] != 0) continue;
    circle[g[s][i]] = dl + 1;
    dfs(g[s][i], dl + 1);
  }
}
