#include <bits/stdc++.h>
using namespace std;
struct node {
  int v, next;
} e[10000];
int d[3005];
int head[3005];
int n, idx;
bool vis[3005];
int du[3005];
void add(int u, int v) {
  e[idx].v = v;
  e[idx].next = head[u];
  head[u] = idx++;
}
void dfs(int t) {
  int i, j;
  for (i = head[t]; i != -1; i = e[i].next) {
    int v = e[i].v;
    if (vis[v]) {
      vis[v] = 0;
      d[v] = d[t] + 1;
      dfs(v);
    }
  }
}
int main() {
  int i, j;
  memset(head, -1, sizeof(head));
  idx = 0;
  int a, b;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a >> b;
    du[a]++;
    du[b]++;
    add(a, b);
    add(b, a);
  }
  while (1) {
    int tag = 0;
    for (i = 1; i <= n; i++) {
      if (!vis[i] && du[i] == 1) {
        vis[i] = 1;
        tag = 1;
        for (j = head[i]; j != -1; j = e[j].next) {
          if (!vis[e[j].v]) {
            du[e[j].v]--;
          }
        }
      }
    }
    if (!tag) break;
  }
  bool w[3005];
  for (i = 1; i <= n; i++) w[i] = vis[i];
  for (i = 1; i <= n; i++) {
    if (!w[i]) {
      d[i] = 0;
      dfs(i);
    }
  }
  for (i = 1; i <= n; i++) {
    if (i == 1)
      cout << d[i];
    else
      cout << " " << d[i];
  }
  cout << endl;
}
