#include <bits/stdc++.h>
using namespace std;
int N, used[3011], dad[3011];
vector<int> way[3011];
int dfs(int x, int uz) {
  used[x] = uz;
  int tmp = 0;
  for (int i = 0; i < (int)way[x].size(); i++) {
    if (way[x][i] == x || dad[x] == way[x][i]) continue;
    if (used[way[x][i]] != 0) return used[way[x][i]];
    dad[way[x][i]] = x;
    tmp = dfs(way[x][i], uz + 1);
    if (tmp > -1) return tmp;
  }
  return -1;
}
int main() {
  cin >> N;
  for (int i = 1, a, b; i <= N; i++) {
    cin >> a >> b;
    way[a].push_back(b);
    way[b].push_back(a);
  }
  for (int i = 1; i <= N; i++) {
    cout << dfs(i, 1) - 1 << " ";
    memset(used, 0, sizeof used);
    memset(dad, 0, sizeof dad);
  }
  cout << endl;
  return 0;
}
