#include <bits/stdc++.h>
using namespace std;
vector<int> vis;
vector<int> tim;
int t = -1;
vector<int> r;
int s = -1;
vector<vector<int> > g;
bool dfs(int i, int p) {
  t++;
  tim[i] = t;
  bool b = 0;
  vector<int>::iterator it = g[i].begin();
  for (; it != g[i].end(); it++) {
    if (!vis[*it]) {
      vis[*it] = 1;
      b |= dfs(*it, i);
      if (b) {
        r[i] = 0;
        break;
      }
    } else {
      if (*it != p) {
        if (tim[*it] < tim[i]) {
          b = 1;
          s = *it;
          r[i] = 0;
          break;
        }
      }
    }
  }
  if (s == i) b = 0;
  return b;
}
int dfs2(int i) {
  if (r[i] == 0) return 0;
  bool ch = 0;
  vector<int>::iterator it = g[i].begin();
  int h;
  for (; it != g[i].end(); it++) {
    if (!vis[*it]) {
      vis[*it] = 1;
      h = dfs2(*it);
      if (h < 100000) {
        r[i] = 1 + h;
        ch = 1;
        break;
      }
    }
  }
  if (ch)
    return 1 + h;
  else
    return 100000;
}
int main() {
  int n;
  cin >> n;
  g.resize(n + 1);
  int a, b;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vis.resize(n + 1, 0);
  tim.resize(n + 1);
  vis[1] = 1;
  r.resize(n + 1, -1);
  dfs(1, 0);
  for (int i = 1; i <= n; i++) {
    if (r[i] == -1) {
      vis.clear();
      vis.resize(n + 1, 0);
      vis[i] = 1;
      int k = dfs2(i);
    }
  }
  for (int i = 1; i <= n; i++) cout << r[i] << " ";
  return 0;
}
