#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
vector<int> g[N];
int n, p[N], col[N], d[N];
queue<int> q;
void dfs(int v, int pr) {
  col[v] = 1;
  for (int i = 0; i < g[v].size(); i++)
    if (col[g[v][i]] == 1 && pr != g[v][i]) {
      int first = g[v][i], now = v;
      while (now != first) {
        d[now] = 0;
        q.push(now);
        now = p[now];
      }
      d[first] = 0;
      q.push(first);
    } else if (!col[g[v][i]]) {
      p[g[v][i]] = v;
      dfs(g[v][i], v);
    }
  col[v] = 2;
}
void bfs() {
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (int i = 0; i < g[v].size(); i++)
      if (d[g[v][i]] > d[v] + 1) {
        d[g[v][i]] = d[v] + 1;
        q.push(g[v][i]);
      }
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) d[i] = N;
  int x, y;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    g[--x].push_back(--y);
    g[y].push_back(x);
  }
  dfs(0, -1);
  bfs();
  for (int i = 0; i < n; i++) cout << d[i] << " ";
  return 0;
}
