#include <bits/stdc++.h>
using namespace std;
stack<int> st;
int dfs(vector<int> vec[], vector<bool>& vis, int par) {
  int a, y;
  a = st.top();
  if (vis[a]) {
    return 1;
  }
  vis[a] = true;
  for (auto j : vec[a]) {
    if (j != par) {
      st.push(j);
      y = dfs(vec, vis, a);
      if (y == 1) {
        return 1;
        break;
      }
    }
  }
  st.pop();
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, d, h, i, j, a, b;
  cin >> n;
  vector<int> vec[n + 1];
  vector<bool> vis(n + 1, false);
  vector<bool> tank(n + 1, false);
  for (i = 0; i < n; ++i) {
    cin >> a >> b;
    vec[a].emplace_back(b);
    vec[b].emplace_back(a);
  }
  st.push(1);
  dfs(vec, vis, 1);
  h = st.top();
  st.pop();
  vector<int> ans(n + 1, -1);
  ans[h] = 0;
  queue<int> sque;
  while (st.top() != h) {
    ans[st.top()] = 0;
    st.pop();
  }
  for (i = 1; i < n + 1; ++i) {
    if (ans[i] != 0) continue;
    tank[i] = true;
    for (auto j : vec[i]) {
      if (ans[j] == 0) continue;
      ans[j] = ans[i] + 1;
      sque.push(j);
    }
  }
  while (!sque.empty()) {
    i = sque.front();
    sque.pop();
    if (tank[i]) continue;
    tank[i] = true;
    for (auto j : vec[i]) {
      if (!tank[j]) {
        ans[j] = ans[i] + 1;
        sque.push(j);
      }
    }
  }
  for (i = 1; i < n + 1; ++i) cout << ans[i] << " ";
}
