#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> s[3005];
int tra[3005], f[3004];
queue<int> q;
int uu, vv, u, v;
void dfs(int u) {
  for (typeof(s[u].begin()) it = s[u].begin(); it != s[u].end(); it++) {
    if (tra[*it] == 0)
      tra[*it] = u, dfs(*it);
    else if (tra[u] != *it)
      uu = *it, vv = u;
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &u, &v);
    s[u].push_back(v);
    s[v].push_back(u);
  }
  memset(f, -1, sizeof(f));
  memset(tra, 0, sizeof(tra));
  tra[1] = -1;
  dfs(1);
  while (uu != vv) {
    f[uu] = 0;
    q.push(uu);
    uu = tra[uu];
  }
  f[vv] = 0;
  q.push(vv);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (typeof(s[u].begin()) it = s[u].begin(); it != s[u].end(); it++)
      if (f[*it] == -1) {
        f[*it] = f[u] + 1;
        q.push(*it);
      }
  }
  for (int i = 1; i <= n; i++) printf("%d ", f[i]);
  return 0;
}
