#include <bits/stdc++.h>
template <typename T>
T max(T a, T b) {
  return a > b ? a : b;
}
template <typename T>
T min(T a, T b) {
  return a < b ? a : b;
}
template <typename T>
void read(T &x) {
  x = 0;
  register char ch = getchar();
  register int f = 1;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
  x *= f;
}
int n, top, cnt, tot, flag;
int fir[3005], nx[3005 << 1], to[3005 << 1], dis[3005];
int st[3005], cir[3005];
bool in[3005], is[3005];
void add(int _, int __) {
  nx[++cnt] = fir[_];
  fir[_] = cnt;
  to[cnt] = __;
}
void dfs(int x, int f) {
  st[++top] = x;
  in[x] = 1;
  for (int i = fir[x]; i; i = nx[i]) {
    int v = to[i];
    if (v == f) continue;
    if (in[v]) {
      flag = 1;
      for (register int i = top; i >= 1; --i) {
        cir[++tot] = st[i];
        is[st[i]] = 1;
        if (st[i] == v) break;
      }
      return;
    }
    dfs(v, x);
    if (flag) return;
  }
  --top;
}
void getdis(int x, int f, int dist) {
  dis[x] = dist;
  for (int i = fir[x]; i; i = nx[i]) {
    int v = to[i];
    if (v == f || is[v]) continue;
    getdis(v, x, dist + 1);
  }
}
int main() {
  read(n);
  int x, y;
  for (register int i = 1; i <= n; ++i) read(x), read(y), add(x, y), add(y, x);
  dfs(1, 1);
  for (register int i = 1; i <= tot; ++i) {
    getdis(cir[i], cir[i], 0);
  }
  for (register int i = 1; i <= n; ++i) printf("%d ", dis[i]);
  return 0;
}
