#include <bits/stdc++.h>
using namespace std;
const int maxn = 3010;
bool path[maxn][maxn] = {0};
vector<int> c[maxn];
bool d[maxn] = {0};
int trace[maxn];
int n, root, preroot;
int res[maxn] = {0};
bool circle = false;
bool incir[maxn] = {0};
void dfs(int i) {
  d[i] = true;
  if (circle) return;
  for (int j = 0; j < c[i].size(); j++) {
    if (circle) return;
    int next = c[i][j];
    if (!d[next]) {
      trace[next] = i;
      dfs(next);
    } else if (next != trace[i]) {
      circle = true;
      root = next;
      preroot = i;
      return;
    }
  }
}
void dfs2(int i, int deep) {
  d[i] = true;
  for (int j = 0; j < c[i].size(); j++) {
    int next = c[i][j];
    if (!d[next]) {
      dfs2(next, deep + 1);
    }
  }
  res[i] = deep;
}
void solve() {
  dfs(1);
  int cur = preroot;
  while (true) {
    incir[cur] = true;
    if (cur == root) break;
    cur = trace[cur];
  }
  for (int i = 0; i <= n; i++) {
    if (!incir[i]) {
      d[i] = false;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (incir[i]) {
      dfs2(i, 0);
    }
  }
  for (int i = 1; i <= n; i++) {
    printf("%d ", res[i]);
  }
}
int main() {
  scanf("%d", &n);
  int u, v;
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &u, &v);
    c[u].push_back(v);
    c[v].push_back(u);
  }
  solve();
  return 0;
}
