#include <bits/stdc++.h>
using namespace std;
const int N = 6500;
const int E = 10000;
const int oo = 100000000;
int t;
int n;
int m;
int q;
int ne;
int ne2;
int top;
int ans;
int bcnt;
int root;
int dindex;
int br[E];
int low[N];
int dfn[N];
int fat[N];
int par[N];
int con[N];
int head[N];
int Rank[N];
int head2[N];
int stack[N];
int level[N];
bool bridge[E];
bool vis[N];
struct Edge {
  int x, y;
  int nxt;
} bf[E], bf2[E];
void addedge(int x, int y, Edge bf[], int head[], int &ne) {
  bf[ne].x = x;
  bf[ne].y = y;
  bf[ne].nxt = head[x];
  head[x] = ne++;
}
int find_set(int x) {
  if (par[x] < 0) return x;
  par[x] = find_set(par[x]);
  return par[x];
}
int union_set(int x, int y) {
  x = find_set(x);
  y = find_set(y);
  if (x == y) return x;
  if (Rank[x] > Rank[y]) {
    par[y] = x;
    return x;
  }
  par[x] = y;
  if (Rank[x] == Rank[y]) Rank[y]++;
  return y;
}
void tar(int i, int fa, int fb) {
  dfn[i] = low[i] = ++dindex;
  int j;
  int a, b;
  for (j = head[i]; j; j = bf[j].nxt) {
    int v = bf[j].y;
    if (!vis[v]) {
      vis[v] = 1;
      tar(v, i, j);
      low[i] = min(low[i], low[v]);
      if (low[v] > dfn[i]) {
        bridge[j] = 1;
        br[++bcnt] = j;
      } else {
        a = find_set(i);
        b = find_set(v);
        union_set(a, b);
      }
    } else if (fa != v || (fb && abs(fb - j) > 1))
      low[i] = min(low[i], dfn[v]);
  }
}
void find_bridge() {
  memset(bridge, 0, sizeof(bridge));
  dindex = bcnt = 0;
  memset(vis, 0, sizeof(vis));
  memset(par, -1, sizeof(par));
  memset(Rank, 0, sizeof(Rank));
  memset(dfn, 0, sizeof(dfn));
  vis[1] = 1;
  tar(1, -1, 0);
}
int dist[3030];
int que[3030];
void spfa(int src, int n) {
  int i;
  for (i = 0; i <= n + 1; i++) {
    dist[i] = oo;
    vis[i] = 0;
  }
  vis[src] = 1;
  dist[src] = 0;
  int f = 0;
  int r = 1;
  que[0] = src;
  while (f != r) {
    int now = que[f++];
    if (f == N) f = 0;
    vis[now] = 0;
    for (i = head2[now]; i; i = bf2[i].nxt) {
      int y = bf2[i].y;
      if (dist[y] > dist[now] + 1) {
        dist[y] = dist[now] + 1;
        if (!vis[y]) {
          vis[y] = 1;
          que[r++] = y;
          if (r == N) r = 0;
        }
      }
    }
  }
}
void solve() {
  int a, b, i, cnt = 0;
  memset(con, -1, sizeof(con));
  int ring = 1;
  for (ans = bcnt, i = 1; i <= n; i++) {
    a = find_set(i);
    if (con[a] == -1)
      con[a] = ++cnt;
    else
      ring = con[a];
    con[i] = con[a];
  }
  for (i = 1; i <= bcnt; i++) {
    addedge(con[bf[br[i]].x], con[bf[br[i]].y], bf2, head2, ne2);
    addedge(con[bf[br[i]].y], con[bf[br[i]].x], bf2, head2, ne2);
  }
  spfa(ring, cnt);
  for (i = 1; i < n; i++) {
    printf("%d ", dist[con[i]]);
  }
  printf("%d\n", dist[con[i]]);
}
int main() {
  while (scanf("%d", &n) != EOF) {
    t++;
    ne = 2;
    ne2 = 2;
    memset(head, 0, sizeof(head));
    memset(head2, 0, sizeof(head2));
    int i, j;
    int x, y;
    for (i = 0; i < n; i++) {
      scanf("%d%d", &x, &y);
      addedge(x, y, bf, head, ne);
      addedge(y, x, bf, head, ne);
    }
    find_bridge();
    solve();
  }
}
