#include <bits/stdc++.h>
using namespace std;
int MAX(long long int a, long long int b) {
  if (a > b) {
    return a;
  } else {
    return b;
  }
}
int MIN(long long int a, long long int b) {
  if (a < b) {
    return a;
  } else {
    return b;
  }
}
int gcd(long long int a, long long int b) {
  long long int c;
  while (a != 0) {
    c = a;
    a = b % a;
    b = c;
  }
  return b;
}
int n;
int way[3005][3005];
int tway[3005][3005];
int st[3005];
int push = 0;
int deg[3005] = {0};
int tree[3005];
int dist[3005];
void dfs(int k, int t) {
  dist[k] = t;
  for (int i = 1; i <= n; i++) {
    if (tree[i] && way[k][i] && !dist[i]) {
      dfs(i, t + 1);
    }
  }
}
int main() {
  cin >> n;
  int i;
  int a, b;
  for (i = 1; i <= n; i++) {
    cin >> a >> b;
    way[a][b] = 1;
    way[b][a] = 1;
    tway[a][b] = 1;
    tway[b][a] = 1;
    deg[a]++;
    deg[b]++;
  }
  for (i = 1; i <= n; i++) {
    if (deg[i] == 1) {
      st[push] = i;
      push++;
    }
  }
  while (1) {
    if (push <= 0) {
      break;
    }
    int tmp = st[push - 1];
    tree[tmp] = 1;
    push--;
    for (i = 1; i <= n; i++) {
      if (tway[tmp][i] == 1) {
        tway[tmp][i] = 0;
        tway[i][tmp] = 0;
        deg[i]--;
        if (deg[i] == 1) {
          st[push] = i;
          push++;
        }
        break;
      }
    }
  }
  for (i = 1; i <= n; i++) {
    if (tree[i] == 0) {
      dfs(i, 1);
    }
  }
  for (i = 1; i <= n; i++) {
    printf("%d ", dist[i] - 1);
  }
  return 0;
}
