#include <bits/stdc++.h>
using namespace std;
vector<int> v[3005];
int l[3005];
int dfs(int x, int len, int y) {
  int j, t;
  l[x] = len;
  for (j = 0; j < v[x].size(); j++) {
    if (v[x][j] == y) continue;
    if (l[v[x][j]] > 0) return l[v[x][j]];
    t = dfs(v[x][j], len + 1, x);
    if (t > -1) return t;
  }
  return -1;
}
int main() {
  int n, x, y, i, j;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  for (i = 1; i <= n; i++) {
    cout << dfs(i, 1, 0) - 1 << " ";
    for (j = 0; j < 3005; j++) l[j] = 0;
  }
  return 0;
}
