#include <bits/stdc++.h>
using namespace std;
vector<int> lista[3009];
int ciclo[3009];
int niv[3009];
int dfs(int v, int pai) {
  niv[v] = 1;
  int sz = lista[v].size();
  for (int i = 0; i < sz; i++) {
    if (niv[lista[v][i]] != -1) {
      if (lista[v][i] != pai) {
        ciclo[v] = 1;
        return lista[v][i];
      }
      continue;
    }
    int r = dfs(lista[v][i], v);
    if (r == -2) continue;
    if (r == -1) return -1;
    if (v != r) {
      ciclo[v] = 1;
      return r;
    } else if (v == r) {
      ciclo[v] = 1;
      return -1;
    }
  }
  return -2;
}
int main(void) {
  int n, a, b;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &a, &b);
    a--;
    b--;
    lista[a].push_back(b);
    lista[b].push_back(a);
  }
  memset(ciclo, 0, sizeof(ciclo));
  memset(niv, -1, sizeof(niv));
  dfs(0, -1);
  memset(niv, -1, sizeof(niv));
  queue<int> fila;
  for (int i = 0; i < n; i++) {
    if (ciclo[i]) {
      fila.push(i);
      niv[i] = 0;
    }
  }
  while (!fila.empty()) {
    int u = fila.front();
    fila.pop();
    int sz = lista[u].size();
    for (int i = 0; i < sz; i++) {
      if (niv[lista[u][i]] != -1) continue;
      niv[lista[u][i]] = niv[u] + 1;
      fila.push(lista[u][i]);
    }
  }
  for (int i = 0; i < n; i++) {
    if (i) printf(" ");
    printf("%d", niv[i]);
  }
  return 0;
}
