#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int inf = 0x3f3f3f3f;
const long long oo = 1LL << 60;
const int N = 10010;
const int E = 200010;
class Graph {
 public:
  int pnt[E], nxt[E], id[E];
  int head[N], nv, ne;
  void init(const int v) {
    nv = v;
    ne = 0;
    memset(head, 255, sizeof(head));
  }
  void add(const int u, const int v, const int i) {
    pnt[ne] = v, id[ne] = i, nxt[ne] = head[u], head[u] = ne++;
    pnt[ne] = u, id[ne] = i, nxt[ne] = head[v], head[v] = ne++;
  }
} ga, gb;
int n, rt;
int dfn[N], low[N], idx;
int stk[N], top;
int belong[N], bcnt;
bool vis[N];
int cnt[N];
void dfs(const Graph &g, int u, int f) {
  int i, v, e;
  dfn[u] = low[u] = idx++;
  stk[++top] = u;
  vis[u] = 1;
  for (i = g.head[u]; ~i; i = g.nxt[i]) {
    v = g.pnt[i], e = g.id[i];
    if (dfn[v] < 0) {
      dfs(g, v, e);
      low[u] = min(low[u], low[v]);
    } else if (e != f && vis[v] && low[u] > dfn[v])
      low[u] = dfn[v];
  }
  if (dfn[u] == low[u]) {
    do {
      v = stk[top--];
      vis[v] = 0;
      belong[v] = bcnt;
    } while (v != u);
    bcnt++;
  }
}
void bcc(const Graph &g) {
  top = bcnt = idx = 0;
  memset(dfn, 255, sizeof(dfn));
  memset(vis, 0, sizeof(vis));
  for (int i = 0; i < g.nv; i++)
    if (dfn[i] < 0) dfs(g, i, -1);
}
void find(const Graph &g) {
  rt = -1;
  int mm = -1;
  memset(cnt, 0, sizeof(cnt));
  for (int i = 0; i < g.nv; i++) cnt[belong[i]]++;
  for (int i = 0; i < bcnt; i++)
    if (cnt[i] > mm) {
      mm = cnt[i];
      rt = i;
    }
}
void shrink(const Graph &ga, Graph &gb) {
  int v, cnt = 1;
  gb.init(bcnt);
  for (int i = 0; i < ga.nv; i++)
    for (int j = ga.head[i]; ~j; j = ga.nxt[j])
      if (belong[i] != belong[v = ga.pnt[j]])
        gb.add(belong[i], belong[v], cnt++);
}
bool in[N];
int Q[N], dist[N];
void spfa(const Graph &g, int src) {
  int i, u, v, l, r = 0;
  memset(dist, 63, sizeof(dist));
  memset(in, 0, sizeof(in));
  dist[Q[r++] = src] = 0;
  in[src] = 1;
  for (l = 0; l != r; l = (l + 1) % N)
    for (i = g.head[u = Q[l]], in[u] = 0; ~i; i = g.nxt[i])
      if (dist[v = g.pnt[i]] > dist[u] + 1) {
        dist[v] = dist[u] + 1;
        if (!in[v]) in[Q[r++] = v] = 1, r %= N;
      }
}
int main(void) {
  scanf("%d", &n);
  ga.init(n);
  for (int i = 1; i <= n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    ga.add(u - 1, v - 1, i);
  }
  bcc(ga);
  find(ga);
  shrink(ga, gb);
  spfa(gb, rt);
  for (int i = 0; i < ga.nv; i++)
    printf("%d%c", dist[belong[i]], i == ga.nv - 1 ? '\n' : ' ');
  return 0;
}
