#include <bits/stdc++.h>
using namespace std;
const int maxn = 3000 + 5;
vector<int> u[maxn];
int d[maxn], a[maxn][maxn], v[maxn], n;
void dfs(int u) {
  for (int i = 1; i <= n; i++) {
    if (i != u && d[i] == -1 && a[u][i] == 1) {
      d[i] = d[u] + 1;
      dfs(i);
    }
  }
}
int main() {
  memset(a, 0, sizeof(a));
  memset(d, -1, sizeof(d));
  memset(v, 0, sizeof(v));
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    a[x][y] = a[y][x] = 1;
    u[x].push_back(y);
    u[y].push_back(x);
    v[x]++;
    v[y]++;
  }
  while (1) {
    int flag = 0;
    for (int i = 1; i <= n; i++)
      if (v[i] == 1) {
        flag = 1;
        v[i]--;
        for (int j = 0; j < u[i].size(); j++) v[u[i][j]]--;
        break;
      }
    if (!flag) break;
  }
  for (int i = 1; i <= n; i++)
    if (v[i] >= 2) d[i] = 0;
  for (int i = 1; i <= n; i++)
    if (d[i] == 0) dfs(i);
  for (int i = 1; i <= n; i++) {
    if (i == 1)
      printf("%d", d[i]);
    else
      printf(" %d", d[i]);
  }
  printf("\n");
}
