#include <bits/stdc++.h>
static int G[3002][3002], sz[3002], ans[3002], Q[3002], D[3002], P[3002];
static bool M[3002], ring;
static int n, qit;
void ring_found(int v, int w) {
  qit = 0;
  if (D[v] > D[w]) {
    Q[qit++] = w;
    ans[w] = 0;
    while (v != w) {
      Q[qit++] = v;
      ans[v] = 0;
      v = P[v];
    }
  } else {
    Q[qit++] = v;
    ans[v] = 0;
    while (v != w) {
      Q[qit++] = w;
      ans[w] = 0;
      w = P[w];
    }
  }
}
void dfs(int s) {
  int d;
  M[s] = 1;
  if (ring) return;
  for (int i = 0; i != sz[s]; i++) {
    d = G[s][i];
    if (P[s] == d) continue;
    if (!M[d]) {
      P[d] = s;
      D[d] = D[s] + 1;
      dfs(d);
    } else if (!ring) {
      ring = true;
      ring_found(s, d);
      return;
    }
  }
}
int main() {
  memset(sz, 0, sizeof sz);
  memset(M, 0, sizeof M);
  memset(ans, -1, sizeof ans);
  int x, y;
  scanf("%d", &n);
  for (int i = 0; i != n; i++) {
    scanf("%d%d", &x, &y);
    x--;
    y--;
    G[x][sz[x]++] = y;
    G[y][sz[y]++] = x;
  }
  D[0] = 0;
  dfs(0);
  int ini2, fim2, ini, fim;
  ini = 0;
  fim = qit;
  ini2 = fim2 = fim;
  while (ini != fim) {
    int v = Q[ini++];
    for (int i = 0; i != sz[v]; i++) {
      int w = G[v][i];
      if (ans[w] == -1) {
        ans[w] = ans[v] + 1;
        Q[fim++] = w;
      }
    }
  }
  for (int i = 0; i != n; i++) printf("%d%s", ans[i], i == n - 1 ? "\n" : " ");
  return 0;
}
