#include <bits/stdc++.h>
using namespace std;
vector<int> graph[3100];
bool chkedge[3100][3100];
int dis[3100], loop;
bool chk[3100], getloop;
void dfs(int idx) {
  chk[idx] = true;
  int len = graph[idx].size();
  for (int i = 0; i < len && !getloop; i++) {
    int nxt = graph[idx][i];
    if (chkedge[idx][nxt]) continue;
    if (!chk[nxt]) {
      chkedge[idx][nxt] = true;
      chkedge[nxt][idx] = true;
      dfs(nxt);
    } else
      loop = nxt, getloop = true;
  }
  if (getloop && idx != loop && loop != -1)
    dis[idx] = 0;
  else if (getloop && idx == loop) {
    dis[idx] = 0, loop = -1;
  }
}
int main() {
  memset(dis, 255, sizeof(dis));
  memset(chk, 0, sizeof(chk));
  getloop = false;
  loop = 0;
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  for (int i = 1; i <= n && !getloop; i++) {
    if (!chk[i]) dfs(i);
  }
  memset(chk, 0, sizeof(chk));
  queue<int> q;
  for (int i = 1; i <= n; i++) {
    if (dis[i] == 0) q.push(i), chk[i] = true;
  }
  while (!q.empty()) {
    int nl = q.front();
    q.pop();
    int len = graph[nl].size();
    for (int i = 0; i < len; i++) {
      int nxt = graph[nl][i];
      if (!chk[nxt]) {
        q.push(nxt);
        chk[nxt] = true;
        dis[nxt] = dis[nl] + 1;
      }
    }
  }
  for (int i = 1; i <= n; i++) printf("%d ", dis[i]);
  printf("\n");
  return 0;
}
