#include <bits/stdc++.h>
using namespace std;
int l[3001][3001];
int c[3001];
int p[3001];
bool v[3001];
bool incycle[3001];
int dist[3001];
bool DFS(int st) {
  for (int i = 0; i < c[st]; i++) {
    int st2 = l[st][i];
    int back = p[st2];
    if (st2 == p[st]) continue;
    if (incycle[st2]) {
      int temp = p[st2];
      while (temp) {
        incycle[temp] = false;
        temp = p[temp];
      }
      return true;
    } else {
      incycle[st2] = true;
      p[st2] = st;
      if (DFS(st2))
        return true;
      else {
        incycle[st2] = false;
        p[st2] = back;
      }
    }
  }
  return false;
}
int main() {
  int n;
  cin >> n;
  int a, b;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    l[a][c[a]] = b;
    c[a]++;
    l[b][c[b]] = a;
    c[b]++;
  }
  incycle[1] = true;
  DFS(1);
  list<int> cur;
  for (int i = 1; i <= n; i++) {
    if (incycle[i]) {
      cur.push_back(i);
      v[i] = true;
    } else
      v[i] = false;
  }
  while (true) {
    int len = cur.size();
    if (!len) break;
    list<int>::iterator it = cur.begin();
    for (int i = 0; i < len; i++) {
      int st = *it;
      for (int j = 0; j < c[st]; j++) {
        int st2 = l[st][j];
        if (!v[st2]) {
          dist[st2] = dist[st] + 1;
          v[st2] = true;
          cur.push_back(st2);
        }
      }
      it++;
    }
    while (len--) cur.pop_front();
  }
  for (int i = 1; i <= n; i++) {
    cout << dist[i];
    if (i < n)
      cout << " ";
    else
      cout << endl;
  }
  return 0;
}
