#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > v(3005);
queue<int> q;
int u[3005], d[3005], p[3005];
void dfs(int cur) {
  u[cur] = 1;
  int i, x, y;
  for (i = 0; i < v[cur].size(); i++) {
    x = v[cur][i];
    if (u[x] == 0) {
      p[x] = cur;
      dfs(x);
    } else {
      if (p[cur] != x) {
        y = cur;
        while (y != x) {
          q.push(y);
          d[y] = 0;
          y = p[y];
        }
        d[y] = 0;
        q.push(y);
      }
    }
    if (q.size() > 0) {
      return;
    }
  }
}
int i, j, k, n, m, x, y, z, t;
int main() {
  memset(d, -1, sizeof(d));
  memset(p, -1, sizeof(p));
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> x >> y;
    x--;
    y--;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  dfs(0);
  while (!q.empty()) {
    x = q.front();
    q.pop();
    for (i = 0; i < v[x].size(); i++) {
      y = v[x][i];
      if (d[y] == -1) {
        d[y] = d[x] + 1;
        q.push(y);
      }
    }
  }
  for (i = 0; i < n; i++) {
    cout << d[i] << ' ';
  }
  cout << endl;
  return 0;
}
