#include <bits/stdc++.h>
using namespace std;
int n;
struct node {
  int v, w;
} e;
vector<node> vc[3005];
int len[3005], ans;
void dfs(int u, int juli, int bian) {
  if (ans >= 0) return;
  len[u] = juli;
  int i, v;
  for (i = vc[u].size() - 1; i >= 0; i--) {
    if (ans >= 0) return;
    if (vc[u][i].w == bian) continue;
    v = vc[u][i].v;
    if (len[v] >= 0) {
      ans = len[v];
      return;
    }
    dfs(v, juli + 1, vc[u][i].w);
  }
}
int main() {
  scanf("%d", &n);
  int a, b, i;
  for (i = 0; i < n; i++) {
    scanf("%d%d", &a, &b);
    e.v = b;
    e.w = i;
    vc[a].push_back(e);
    e.v = a;
    vc[b].push_back(e);
  }
  for (i = 1; i <= n; i++) {
    memset(len, -1, sizeof(len));
    ans = -1;
    dfs(i, 0, -1);
    printf("%d ", ans);
  }
  return 0;
}
