#include <bits/stdc++.h>
using namespace std;
const int N = 3030;
vector<int> son[N];
struct Edge {
  int u, v;
  int nxt;
  int w;
};
Edge e[N << 3];
int ect;
int h[N];
void _add(int u, int v, int w) {
  e[ect].u = u;
  e[ect].v = v;
  e[ect].w = w;
  e[ect].nxt = h[u];
  h[u] = ect++;
}
int scc;
int col[N], sz[N];
int sta[N], dfn[N], low[N], top, ti;
bool vis[N];
int dis[N];
void tarjan(int u, int fa) {
  sta[++top] = u;
  vis[u] = 1;
  dfn[u] = low[u] = ++ti;
  for (int v : son[u]) {
    if (v == fa) continue;
    if (!dfn[v]) {
      tarjan(v, u);
      low[u] = min(low[u], low[v]);
    } else if (vis[v])
      low[u] = min(low[u], dfn[v]);
  }
  if (low[u] == dfn[u]) {
    scc++;
    do {
      vis[sta[top]] = 0;
      col[sta[top]] = scc;
      sz[scc]++;
    } while (u != sta[top--]);
  }
}
void init() {
  ect = scc = top = ti = 0;
  memset(h, -1, sizeof(h));
  memset(vis, 0, sizeof(vis));
}
void get(int x, int di) {
  dis[x] = di;
  for (int v : son[x])
    if (dis[v] < 0) get(v, di + 1);
}
int main() {
  init();
  int n;
  scanf("%d", &n);
  for (int i = 0, u, v; i < n; i++) {
    scanf("%d%d", &u, &v);
    son[u].push_back(v);
    son[v].push_back(u);
  }
  tarjan(1, 0);
  memset(dis, -1, sizeof(dis));
  for (int i = 1; i <= n; i++)
    if (sz[col[i]] > 2) dis[i] = 0;
  for (int i = 1; i <= n; i++)
    if (dis[i] == 0) get(i, 0);
  for (int i = 1; i <= n; i++) printf("%d ", dis[i]);
  return 0;
}
