#include <bits/stdc++.h>
using namespace std;
int fix[1000000];
int a, b, h, i, j, per, cur, ans, n, m, k;
bool flag;
vector<long> c[1000000];
queue<pair<int, int> > q;
void go(int x, int plo) {
  if (!flag) {
    fix[x] = 1;
    for (int h = 0; h < c[x].size(); h++)
      if (c[x][h] == i && c[x][h] != plo) {
        flag = true;
      } else if (fix[c[x][h]] == 0)
        go(c[x][h], x);
    if (!flag) fix[x] = 0;
  }
}
int fnd(int x) {
  if (fix[x] == 1) return 0;
  per++;
  while (!q.empty()) q.pop();
  ans = 0;
  q.push(make_pair(x, 0));
  while (!q.empty()) {
    pair<int, int> u = q.front();
    q.pop();
    if (fix[u.first] == 1) return u.second;
    fix[u.first] = per;
    for (int h = 0; h < c[u.first].size(); h++)
      if (fix[c[u.first][h]] != per)
        q.push(make_pair(c[u.first][h], u.second + 1));
  }
}
int main() {
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a >> b;
    c[a].push_back(b);
    c[b].push_back(a);
  }
  per = 10;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) fix[j] = 0;
    flag = false;
    go(i, 1000000);
    if (flag) {
      for (k = 1; k <= n; k++) cout << fnd(k) << " ";
      return 0;
    }
  }
}
