#include <bits/stdc++.h>
using namespace std;
vector<int> p[3002];
bool vis[3002];
int n, pre[3002], ans[3002];
queue<int> q;
bool dfs(int x) {
  vis[x] = true;
  for (int i = 0; i < p[x].size(); ++i) {
    if (!vis[p[x][i]]) {
      pre[p[x][i]] = x;
      if (dfs(p[x][i])) return true;
    } else if (pre[x] != p[x][i]) {
      q.push(p[x][i]);
      ans[p[x][i]] = 0;
      for (int j = x; j != p[x][i]; j = pre[j]) {
        ans[j] = 0;
        q.push(j);
      }
      return true;
    }
  }
  return false;
}
int main() {
  scanf("%d", &n);
  int _ = n, x, y;
  while (_--) {
    scanf("%d%d", &x, &y);
    p[x].push_back(y);
    p[y].push_back(x);
    ans[_ + 1] = -1;
  }
  dfs(1);
  while (!q.empty()) {
    int t = q.front();
    q.pop();
    for (int i = 0; i < p[t].size(); ++i)
      if (-1 == ans[p[t][i]]) {
        ans[p[t][i]] = ans[t] + 1;
        q.push(p[t][i]);
      }
  }
  for (int i = 1; i <= n; ++i) printf("%d%c", ans[i], i == n ? '\n' : ' ');
  return 0;
}
