#include <bits/stdc++.h>
using namespace std;
int ans[3005], fa[3005];
bool mark[3005];
vector<int> Gr[3005];
int n, x, y, cycle;
int gf(int v) {
  if (fa[v] == v)
    return v;
  else {
    fa[v] = gf(fa[v]);
    return fa[v];
  }
}
int dfs(int now, int fat, int dis) {
  ans[now] = dis;
  for (vector<int>::iterator it = Gr[now].begin(); it != Gr[now].end(); ++it)
    if (((*it) != fat) && (!mark[*it])) dfs((*it), now, dis + 1);
  return 0;
}
int dfs2(int now, int fa) {
  mark[now] = true;
  for (vector<int>::iterator it = Gr[now].begin(); it != Gr[now].end(); ++it)
    if ((*it) != fa) {
      if (mark[*it]) {
        cycle = *it;
        return 0;
      } else {
        dfs2(*it, now);
        if (cycle != -1) break;
      }
    }
  if (cycle == now)
    cycle = -1;
  else if (cycle == -1)
    mark[now] = false;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &x, &y);
    Gr[x].push_back(y);
    Gr[y].push_back(x);
  }
  memset(ans, 0, sizeof(ans));
  cycle = -1;
  memset(mark, false, sizeof(mark));
  dfs2(1, 0);
  for (int i = 1; i <= n; ++i)
    if (mark[i]) {
      dfs(i, 0, 0);
    }
  for (int i = 1; i <= n - 1; ++i) printf("%d ", ans[i]);
  printf("%d\n", ans[n]);
}
