#include <bits/stdc++.h>
using namespace std;
bool detect_cycle(vector<vector<int>> &arr, int n, stack<int> &st, int i,
                  vector<int> &vis) {
  vis[i] = 1;
  int par = -1;
  if (st.size()) par = st.top();
  st.push(i);
  for (int j = 0; j < arr[i].size(); j++) {
    if (arr[i][j] == par || arr[i][j] == i)
      continue;
    else {
      if (vis[arr[i][j]]) {
        st.push(arr[i][j]);
        return 1;
      } else {
        int y = detect_cycle(arr, n, st, arr[i][j], vis);
        if (y) return 1;
      }
    }
  }
  st.pop();
  return 0;
}
void dfs(vector<vector<int>> &arr, vector<int> &ans, int curr, int temp,
         int par) {
  for (int j = 0; j < arr[temp].size(); j++) {
    if (ans[arr[temp][j]] != 0 & arr[temp][j] != par) {
      ans[arr[temp][j]] = curr;
      dfs(arr, ans, curr + 1, arr[temp][j], temp);
    }
  }
}
int main() {
  int n;
  cin >> n;
  vector<vector<int>> arr(n + 1);
  for (long long i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    arr[x].push_back(y);
    arr[y].push_back(x);
  }
  stack<int> st;
  vector<int> vis(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      if (detect_cycle(arr, n, st, i, vis)) {
        break;
      }
    }
    while (st.size()) st.pop();
  }
  vector<int> ans(n + 1, -1);
  int top = st.top();
  st.pop();
  stack<int> st2;
  ans[top] = 0;
  st2.push(top);
  while (st.size() && st.top() != top) {
    int temp = st.top();
    st.pop();
    ans[temp] = 0;
    st2.push(temp);
  }
  st = st2;
  while (st2.size()) st2.pop();
  while (st.size()) {
    int temp = st.top();
    st.pop();
    dfs(arr, ans, 1, temp, -1);
  }
  for (int i = 1; i <= n; i++) cout << ans[i] << ' ';
  cout << "\n\n";
}
