#include <bits/stdc++.h>
using namespace std;
vector<int> Ady[3002];
int n, x, y;
bool visitados[3002], ciclados[3002];
int Parent[3002], times[3002], resul[3002];
vector<int> lis;
int BFS(int src) {
  memset(visitados, false, n + 1);
  memset(times, 0, sizeof(int) * (n + 1));
  queue<int> cola;
  cola.push(src);
  times[src] = 0;
  visitados[src] = true;
  while (cola.size()) {
    int act = cola.front();
    cola.pop();
    for (vector<int>::iterator i = Ady[act].begin(), End = Ady[act].end();
         i != End; i++)
      if (!visitados[*i]) {
        times[*i] = times[act] + 1;
        if (ciclados[*i]) return times[*i];
        visitados[*i] = true;
        cola.push(*i);
      }
  }
  return 0;
}
void DFS(int root) {
  visitados[root] = true;
  for (vector<int>::iterator i = Ady[root].begin(), End = Ady[root].end();
       i != End; i++)
    if (!visitados[*i]) {
      Parent[*i] = root;
      DFS(*i);
    } else if (Parent[root] != *i) {
      x = root;
      y = *i;
      return;
    }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &x, &y);
    Ady[x].push_back(y);
    Ady[y].push_back(x);
  }
  DFS(1);
  lis.push_back(x);
  ciclados[x] = true;
  while (y != x) {
    ciclados[y] = true;
    lis.push_back(y);
    y = Parent[y];
  }
  for (int i = 1; i <= n; i++)
    if (!ciclados[i]) {
      int act = BFS(i);
      if (act && (resul[i] == 0 || act < resul[i])) resul[i] = act;
    }
  for (int i = 1; i <= n; i++) {
    printf("%d", resul[i]);
    if (i < n) printf(" ");
  }
  return 0;
}
