#include <bits/stdc++.h>
using namespace std;
vector<int> e[3001], u;
int v[3001], d[3001];
bool dfs(int x, int from) {
  if (v[x]++) {
    for (v[x] = -1; u.back() != x; u.pop_back()) v[u.back()] = -1;
    return true;
  }
  u.push_back(x);
  for (size_t i = 0; i < e[x].size(); i++)
    if (e[x][i] != from && dfs(e[x][i], x)) return true;
  u.pop_back();
  return false;
}
int main() {
  int n, x, y;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &x, &y);
    e[x].push_back(y);
    e[y].push_back(x);
  }
  dfs(1, -1);
  u.clear();
  for (int i = 1; i <= n; i++)
    if (v[i] < 0) u.push_back(i);
  for (size_t o = 0; o < u.size(); o++) {
    for (size_t i = 0; i < e[u[o]].size(); i++) {
      int t = e[u[o]][i];
      if (~v[t]) {
        v[t] = -1;
        d[t] = d[u[o]] + 1;
        u.push_back(t);
      }
    }
  }
  for (int i = 1; i <= n; i++) printf("%d ", d[i]);
}
