#include <bits/stdc++.h>
using namespace std;
const int N = 3030;
struct edg {
  int to, nxt;
} e[N * 2];
int p[N];
void add(int x, int y, int &j) {
  e[j].to = y;
  e[j].nxt = p[x];
  p[x] = j++;
  e[j].to = x;
  e[j].nxt = p[y];
  p[y] = j++;
}
bool rng[N];
int beg;
bool vis[N];
bool dfs1(int u, int f) {
  vis[u] = true;
  for (int x = p[u]; x != -1; x = e[x].nxt) {
    int v = e[x].to;
    if (v != f && vis[v]) {
      beg = v;
      rng[v] = true;
      return rng[u] = true;
    }
    if (v != f && !vis[v])
      if (dfs1(v, u) && v != beg) return rng[u] = true;
  }
  return false;
}
int dp[N];
void dfs(int u, int f, int ans) {
  dp[u] = rng[u] ? 0 : ans;
  for (int x = p[u]; x != -1; x = e[x].nxt) {
    int v = e[x].to;
    if (v != f && v != beg) dfs(v, u, rng[u] ? 1 : ans + 1);
  }
}
int main() {
  int n;
  scanf("%d", &n);
  memset(p, -1, sizeof(p));
  int j = 0;
  for (int i = 1; i <= n; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    add(x, y, j);
  }
  memset(rng, 0, sizeof(rng));
  memset(vis, 0, sizeof(vis));
  dfs1(n, -1);
  dfs(beg, -1, 0);
  for (int i = 1; i <= n; ++i) printf("%d%c", dp[i], i == n ? '\n' : ' ');
  return 0;
}
