#include <bits/stdc++.h>
using namespace std;
vector<int> E[3010];
vector<int> cycle;
bool vis[3010];
bool cy[3010];
int ans[3010];
void DFS(int now, int par) {
  vis[now] = true;
  for (int i = 0; i < E[now].size(); i++) {
    if (E[now][i] != par && vis[E[now][i]]) {
      cycle.push_back(E[now][i]);
      cycle.push_back(now);
      return;
    }
    if (E[now][i] != par) DFS(E[now][i], now);
    if (cycle.size() && cycle[0] != cycle[cycle.size() - 1]) {
      cycle.push_back(now);
      return;
    }
  }
  return;
}
void getans(int now, int dis) {
  ans[now] = dis;
  for (int i = 0; i < E[now].size(); i++)
    if (!cy[E[now][i]] && ans[E[now][i]] == 0) getans(E[now][i], dis + 1);
  return;
}
int main(void) {
  int N, a, b;
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d%d", &a, &b);
    E[a].push_back(b);
    E[b].push_back(a);
  }
  memset(vis, false, sizeof(vis));
  DFS(1, 0);
  memset(cy, false, sizeof(cy));
  for (int i = 0; i < cycle.size(); i++) cy[cycle[i]] = true;
  for (int i = 1; i < cycle.size(); i++) getans(cycle[i], 0);
  printf("%d", ans[1]);
  for (int i = 2; i <= N; i++) printf(" %d", ans[i]);
  return 0;
}
