#include <bits/stdc++.h>
using namespace std;
int n;
vector<vector<int> > ed;
int ns[3005];
bool incycle[3005];
bool notagain[3005];
bool flag[3005];
int path[3005];
int ans[3005];
void solve(int ind, int last, int dep) {
  ans[ind] = dep;
  int c, c2;
  for (c = 0; c < ns[ind]; c++) {
    if (ed[ind][c] == last) continue;
    if (incycle[ed[ind][c]]) continue;
    solve(ed[ind][c], ind, dep + 1);
  }
  return;
}
void savecycle(int from, int ncyc) {
  int c, c2;
  bool now = 0;
  for (c = 0; c < ncyc; c++) {
    if (path[c] == from) now = 1;
    if (!now) continue;
    incycle[path[c]] = 1;
  }
  return;
}
void getcycle(int ind, int last, int cnt) {
  if (notagain[ind]) return;
  if (flag[ind]) {
    savecycle(ind, cnt);
    return;
  }
  flag[ind] = 1;
  int c, c2;
  for (c = 0; c < ns[ind]; c++) {
    if (ed[ind][c] == last) continue;
    path[cnt] = ed[ind][c];
    getcycle(ed[ind][c], ind, cnt + 1);
  }
  flag[ind] = 0;
  notagain[ind] = 1;
  return;
}
int main() {
  FILE *in = stdin;
  int c, c2;
  fscanf(in, "%d", &n);
  ed.resize(n);
  for (c = 0; c < n; c++) {
    int t1, t2;
    fscanf(in, "%d%d", &t1, &t2);
    t1--;
    t2--;
    ed[t1].push_back(t2);
    ed[t2].push_back(t1);
    ns[t1]++;
    ns[t2]++;
  }
  memset(incycle, 0, sizeof(incycle));
  memset(notagain, 0, sizeof(notagain));
  memset(flag, 0, sizeof(flag));
  path[0] = 0;
  getcycle(0, -1, 1);
  for (c = 0; c < n; c++) {
    if (!incycle[c]) continue;
    solve(c, -1, 0);
  }
  for (c = 0; c < n; c++) {
    if (c) printf(" ");
    printf("%d", ans[c]);
  }
  printf("\n");
  return 0;
}
