#include <bits/stdc++.h>
using namespace std;
class sp {
 public:
  short int q;
  sp *w;
};
sp *a[3000];
bool s[3000], s1[3000];
short int v = -1;
bool l(short int q, short int w) {
  s[q] = 0;
  sp *e = a[q];
  bool x = 0;
  while (e != 0) {
    if ((e->q != w) && (q != v))
      if (!s[e->q]) {
        x = 1;
        v = e->q;
        s1[q] = 0;
        s1[e->q] = 0;
      } else if (l(e->q, q)) {
        x = 1;
        s1[q] = 0;
      }
    e = e->w;
  }
  if (q == v) return 0;
  return x;
}
void k(short int q, short int w, short int r) {
  sp *e = a[q];
  if (!s1[q]) {
    v = r;
    return;
  }
  while (e) {
    if (e->q != w) k(e->q, q, r + 1);
    e = e->w;
  }
}
int main() {
  short int q, w, e, r, t;
  cin >> q;
  for (w = 0; w < q; w++) {
    a[w] = 0;
    s[w] = s1[w] = 1;
  }
  sp *c;
  for (w = 0; w < q; w++) {
    cin >> e >> r;
    e--;
    r--;
    c = new sp;
    c->q = r;
    c->w = a[e];
    a[e] = c;
    c = new sp;
    c->q = e;
    c->w = a[r];
    a[r] = c;
  }
  bool m = l(0, -1);
  for (w = 0; w < q; w++) {
    k(w, -1, 0);
    cout << v << " ";
  }
  return 0;
}
