#include <bits/stdc++.h>
using namespace std;
int n, cnt, head[30005], mark[30005], s[30005], u[30005], v[30005], r, t,
    c[30005], circle, ans[30005];
bool vis[30005], flag[30005];
struct Edge {
  int next, to;
} edge[30005 << 1];
inline void add(int u, int v) {
  edge[++cnt].next = head[u];
  edge[cnt].to = v;
  head[u] = cnt;
}
void dfs1(int p) {
  vis[p] = 1;
  for (int i = head[p]; i; i = edge[i].next) {
    int v = edge[i].to;
    if (!vis[v]) {
      flag[i] = 1;
      dfs1(v);
    }
  }
  s[++r] = p;
}
void dfs2(int p) {
  vis[p] = 1;
  mark[p] = t;
  c[t]++;
  for (int i = head[p]; i; i = edge[i].next) {
    if (flag[i]) continue;
    int v = edge[i].to;
    if (!vis[v]) dfs2(v);
  }
}
void dfs3(int p, int depth) {
  vis[p] = 1;
  ans[p] = depth;
  for (int i = head[p]; i; i = edge[i].next) {
    int v = edge[i].to;
    if (!vis[v]) dfs3(v, depth + 1);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &u[i], &v[i]);
    add(u[i], v[i]);
    add(v[i], u[i]);
  }
  dfs1(1);
  memset(vis, 0, sizeof(vis));
  for (int i = n; i >= 1; i--) {
    t++;
    if (!mark[s[i]]) dfs2(s[i]);
  }
  cnt = 0;
  memset(head, 0, sizeof(head));
  for (int i = 1; i <= t; i++) {
    add(mark[u[i]], mark[v[i]]);
    add(mark[v[i]], mark[u[i]]);
    if (c[i] > 1) circle = i;
  }
  memset(vis, 0, sizeof(vis));
  dfs3(circle, 0);
  for (int i = 1; i <= n; i++)
    if (mark[i] != circle)
      printf("%d ", ans[mark[i]]);
    else
      printf("0 ");
  return 0;
}
