#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T sqr(T x) {
  return x * x;
}
const int maxn = 4000;
vector<int> v[maxn];
int n;
int x, y;
bool vis[maxn];
bool c[maxn];
int num = -1;
bool flag = true;
bool mas[maxn][maxn];
bool dfs(int u) {
  if (vis[u] == true) {
    c[u] = true;
    num = u;
    return true;
  }
  vis[u] = true;
  for (int i = 0; i < int(int((v[u]).size())); i++) {
    if (mas[u][v[u][i]] == false) continue;
    mas[u][v[u][i]] = mas[v[u][i]][u] = false;
    if (dfs(v[u][i])) {
      if (u == num) {
        return false;
      } else {
        c[u] = true;
        return true;
      }
    }
  }
  return false;
}
int d[maxn];
void solve() {
  queue<int> q;
  for (int i = 0; i < int(maxn); i++) {
    if (c[i]) {
      q.push(i);
      d[i] = 0;
    }
  }
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = 0; i < int(int((v[u]).size())); i++) {
      if (d[v[u][i]] > d[u] + 1) {
        d[v[u][i]] = d[u] + 1;
        q.push(v[u][i]);
      }
    }
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < int(n); i++) {
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
    mas[x][y] = true;
    mas[y][x] = true;
  }
  dfs(1);
  for (int i = 0; i < int(maxn); i++) d[i] = 2000000000;
  solve();
  for (int i = int(1); i < int(n + 1); i++) printf("%d ", d[i]);
}
