#include <bits/stdc++.h>
using namespace std;
struct node {
  int data;
  int level;
};
int gl = -1;
int st[3100][3100];
int n;
int vis[3100];
int cycle[3100];
int flag = 0;
int ans[3100];
void dfs(int cur, int prev) {
  if (vis[cur] == 1 && flag != 1) {
    flag = 1;
    cycle[cur] = 1;
    gl = cur;
    return;
  }
  if (vis[cur] == 1) return;
  vis[cur] = 1;
  for (int i = 1; i <= n; i++) {
    if (flag == 2) return;
    if (flag == 1) {
      cycle[cur] = 1;
      if (cur == gl) flag = 2;
      return;
    }
    if (st[cur][i] == 1 && i != prev) dfs(i, cur);
  }
  if (flag == 2) return;
  if (flag == 1) {
    cycle[cur] = 1;
    if (cur == gl) flag = 2;
    return;
  }
}
int main() {
  cin >> n;
  int tt = n;
  while (tt--) {
    int t1, t2;
    cin >> t1 >> t2;
    st[t1][t2] = 1;
    st[t2][t1] = 1;
  }
  dfs(1, -1);
  for (int i = 1; i <= n; i++) ans[i] = -1;
  for (int i = 1; i <= n; i++)
    if (cycle[i]) ans[i] = 0;
  for (int i = 1; i <= n; i++) {
    if (cycle[i] == 1) {
      queue<node> Q;
      node temp;
      temp.data = i;
      temp.level = 0;
      Q.push(temp);
      while (!Q.empty()) {
        node te = Q.front();
        Q.pop();
        for (int j = 1; j <= n; j++) {
          if (st[te.data][j] == 1 && ans[j] == -1) {
            node pp;
            pp.data = j;
            pp.level = te.level + 1;
            ans[j] = pp.level;
            Q.push(pp);
          }
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
  cout << endl;
  return 0;
}
