#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> x;
vector<int> rw;
int p[3001], lo[3001], vi[3001];
int q, w;
void dfs(int in, int pr) {
  p[in] = pr;
  if (vi[in]) {
    q = in;
    w = pr;
    return;
  }
  vi[in] = 1;
  for (int i = 0; i < x[in].size(); i++)
    if (x[in][i] != pr) dfs(x[in][i], in);
  vi[in] = 0;
}
void sec(int in, int t) {
  lo[in] = t;
  for (int i = 0; i < x[in].size(); i++)
    if (t + 1 < lo[x[in][i]]) sec(x[in][i], t + 1);
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, a, b;
  cin >> n;
  x = vector<vector<int>>(n + 1);
  memset(p, -1, sizeof p);
  memset(vi, 0, sizeof vi);
  for (int i = 1; i <= n; i++) {
    cin >> a >> b;
    x[a].push_back(b);
    x[b].push_back(a);
    lo[i] = 5000;
  }
  dfs(1, 0);
  rw.push_back(0);
  while (w != q) {
    rw.push_back(w);
    lo[w] = 0;
    w = p[w];
  }
  rw.push_back(q);
  lo[q] = 0;
  rw.push_back(0);
  for (int i = 1; i < rw.size() - 1; i++) sec(rw[i], 0);
  for (int i = 1; i <= n; i++) cout << lo[i] << " ";
  return 0;
}
