#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> v[3005];
int f[3005], cnt;
int low[3005], dfn[3005];
int st[3005], sn;
bool vis[3005];
queue<int> q;
void gao(int x, int fa) {
  dfn[x] = low[x] = ++cnt;
  vis[x] = 1;
  st[++sn] = x;
  for (vector<int>::iterator it = v[x].begin(); it != v[x].end(); ++it)
    if (*it != fa) {
      if (-1 == dfn[*it]) {
        gao(*it, x);
        low[x] = min(low[x], low[*it]);
      } else if (vis[*it])
        low[x] = min(low[x], dfn[*it]);
    }
  if (dfn[x] == low[x]) {
    int cc = 0, p, s0 = sn;
    do {
      p = st[sn--];
      vis[p] = 0;
      ++cc;
    } while (p != x);
    if (cc > 1) {
      sn = s0;
      do {
        p = st[sn--];
        f[p] = 0;
        q.push(p);
        ++cc;
      } while (p != x);
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int x, y;
    scanf("%d %d", &x, &y);
    v[x].push_back(y);
    v[y].push_back(x);
  }
  sn = cnt = 0;
  memset(dfn, -1, sizeof(dfn));
  memset(low, -1, sizeof(low));
  memset(f, -1, sizeof(f));
  gao(1, 0);
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (vector<int>::iterator it = v[x].begin(); it != v[x].end(); ++it)
      if (-1 == f[*it]) {
        f[*it] = f[x] + 1;
        q.push(*it);
      }
  }
  for (int i = 1; i < n; ++i) printf("%d ", f[i]);
  printf("%d\n", f[n]);
  return 0;
}
