#include <bits/stdc++.h>
using namespace std;
vector<int> G[3005];
int dist[3005];
int dfs(int u, int len, int parent) {
  dist[u] = len;
  for (int i = 0; i < G[u].size(); i++) {
    if (G[u][i] == parent)
      continue;
    else if (dist[G[u][i]]) {
      return dist[G[u][i]];
    }
    int newdfs = dfs(G[u][i], len + 1, u);
    if (newdfs != -1) return newdfs;
  }
  return -1;
}
int main() {
  int n;
  scanf("%d", &n);
  int u, v;
  for (int i = 0; i < n; i++) {
    scanf("%d", &u);
    scanf("%d", &v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    cout << dfs(i, 1, 0) - 1 << " ";
    for (int j = 0; j < 3002; j++) {
      dist[j] = 0;
    }
  }
  cout << endl;
  return 0;
}
