#include <bits/stdc++.h>
using namespace std;
int n, a, b, m[3005], d[3005];
vector<int> v[3005];
void dfs(int x, int y) {
  m[x]++;
  for (int j = 0; j < v[x].size(); j++) {
    if (m[v[x][j]] == 0)
      dfs(v[x][j], x);
    else if (v[x][j] != y && x != a) {
      d[x] = 0;
      a = v[x][j];
    }
  }
  if (x != a && d[x] == 0) d[y] = 0;
}
void dfs1(int x) {
  m[x]++;
  for (int j = 0; j < v[x].size(); j++) {
    if (m[v[x][j]] == 0) {
      if (d[v[x][j]] == -1) d[v[x][j]] = d[x] + 1;
      dfs1(v[x][j]);
    }
  }
}
void solve() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    d[i + 1] = -1;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  a = -1;
  dfs(1, 0);
  memset(m, 0, sizeof(m));
  dfs1(a);
  for (int i = 0; i < n; i++) {
    cout << d[i + 1] << " ";
  }
}
int main() {
  int t;
  t = 1;
  while (t--) solve();
}
