#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> a[50005];
int visited[50005], parent[50005];
int dfs(int x, int dep) {
  visited[x] = dep;
  for (long long i = 0; i < a[x].size(); i++) {
    if (parent[x] == a[x][i]) continue;
    if (visited[a[x][i]]) return visited[a[x][i]];
    parent[a[x][i]] = x;
    int t1 = dfs(a[x][i], dep + 1);
    if (t1 != -1) return t1;
  }
  return -1;
}
int main() {
  cin >> n;
  for (long long i = 0; i < n; i++) {
    int x, b;
    cin >> x >> b;
    a[x].push_back(b);
    a[b].push_back(x);
  }
  int ans = 0;
  for (long long i = 1; i < n + 1; i++) {
    memset(visited, 0, sizeof(visited));
    memset(parent, 0, sizeof(parent));
    cout << dfs(i, 1) - 1 << " ";
  }
  return 0;
}
