#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const int mod = 1000000007;
vector<int> adj[3010];
int pai[3010], vis[3010], incycle[3010], flag, ans[3010];
int bfs(int s) {
  int vis[3010], dist[3010];
  memset(vis, 0, sizeof(vis));
  vis[s] = 1;
  dist[s] = 0;
  queue<int> q;
  q.push(s);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    if (incycle[u]) return dist[u];
    for (int i = 0; i < adj[u].size(); i++) {
      int v = adj[u][i];
      if (!vis[v]) {
        vis[v] = 1;
        dist[v] = dist[u] + 1;
        q.push(v);
      }
    }
  }
}
void rec(int u, int last) {
  incycle[u] = 1;
  if (u == last) return;
  rec(pai[u], last);
  return;
}
void find_cycle(int u) {
  if (flag) return;
  vis[u] = 1;
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i];
    if (v == pai[u]) continue;
    if (!vis[v]) {
      pai[v] = u;
      find_cycle(v);
      if (flag) return;
    } else {
      flag = 1;
      rec(u, v);
      return;
    }
  }
  return;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  memset(vis, 0, sizeof(vis));
  flag = 0;
  pai[0] = -1;
  find_cycle(0);
  for (int i = 0; i < n; i++) {
    if (incycle[i]) continue;
    ans[i] = bfs(i);
  }
  for (int i = 0; i < n; i++) {
    printf("%d", ans[i]);
    if (i < n - 1) printf(" ");
  }
  printf("\n");
  return 0;
}
