#include <bits/stdc++.h>
using namespace std;
int p[3003], vis[3003], mark[3003], nd, d[3003];
vector<int> g[3003];
void dfs(int s, int par) {
  vis[s] = 1;
  for (int(i) = (0); (i) < (g[s].size()); (i)++) {
    if (!vis[g[s][i]]) {
      dfs(g[s][i], s);
      if (!p[g[s][i]]) p[g[s][i]] = s;
    } else if (g[s][i] != par) {
      nd = g[s][i];
      if (!p[g[s][i]]) p[g[s][i]] = s;
    }
  }
}
void dfs1(int s) {
  vis[s] = 1;
  for (int(i) = (0); (i) < (g[s].size()); (i)++) {
    if (!vis[g[s][i]] && !mark[g[s][i]]) {
      d[g[s][i]] = d[s] + 1;
      dfs1(g[s][i]);
    }
  }
}
int main() {
  int n;
  scanf("%d", &(n));
  for (int(i) = (0); (i) < (n); (i)++) {
    int u, v;
    scanf("%d%d", &(u), &(v));
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(1, 0);
  memset(vis, 0, sizeof(vis));
  memset(p, 0, sizeof(p));
  dfs(nd, 0);
  int node = p[nd];
  mark[nd] = 1;
  while (node != nd) {
    mark[node] = 1;
    node = p[node];
  }
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= n; ++i) {
    if (mark[i]) {
      dfs1(i);
    }
  }
  for (int i = 1; i <= n; ++i) {
    printf("%d ", d[i]);
  }
  printf("\n");
  return 0;
}
