#include <bits/stdc++.h>
using namespace std;
const double PI = 2.0 * acos(0.0);
const int INF = 1 << 29;
const int MX = 3000;
int f[MX], d[MX], p[MX], cd, cs;
vector<int> G[MX];
void dfs_visit(int u, int pr) {
  int i, v;
  f[u] = 1;
  for (i = 0; i < G[u].size(); i++) {
    v = G[u][i];
    if (f[v] == 0) {
      p[v] = u;
      dfs_visit(v, u);
    } else if (f[v] == 1 && v != pr) {
      cs = v, cd = u;
      return;
    }
  }
  f[u] = 2;
}
int cy[MX];
void dfs() {
  int i, u, v;
  memset(f, 0, sizeof(f));
  p[0] = -1;
  dfs_visit(0, -1);
  memset(cy, 0, sizeof(cy));
  cy[cs] = 1, cy[cd] = 1;
  for (u = cs; u != cd && u != -1; u = p[u]) {
    cy[u] = 1;
  }
}
void bfs(int s) {
  int u, v, i;
  queue<int> Q;
  memset(f, 0, sizeof(f));
  Q.push(s);
  while (!Q.empty()) {
    u = Q.front();
    Q.pop();
    f[u] = 1;
    for (i = 0; i < G[u].size(); i++) {
      v = G[u][i];
      if (f[v] == 0) {
        if (d[v] > d[u] + 1) {
          d[v] = d[u] + 1;
          Q.push(v);
        }
      }
    }
  }
}
int main(void) {
  int N, i, u, v;
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d %d", &u, &v);
    u--, v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  dfs();
  for (i = 0; i < N; i++) d[i] = cy[i] ? 0 : INF;
  for (i = 0; i < N; i++)
    if (cy[i]) bfs(i);
  printf("%d", d[0]);
  for (i = 1; i < N; i++) printf(" %d", d[i]);
  printf("\n");
  return 0;
}
