#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3010;
vector<vector<int> > g;
int n, a, b;
bool used[MAXN];
bool cycle[MAXN];
int dfs(int v, int p) {
  used[v] = true;
  for (int i = 0; i < g[v].size(); i++)
    if (used[g[v][i]] && g[v][i] != p) {
      cycle[g[v][i]] = true;
      cycle[v] = true;
      return g[v][i];
    } else if (!used[g[v][i]]) {
      int x = dfs(g[v][i], v);
      if (v == x) return -2;
      if (x == -2) return -2;
      if (x == -1) continue;
      cycle[v] = true;
      return x;
    }
  return -1;
}
inline int bfs(int v) {
  queue<pair<int, int> > q;
  q.push(make_pair(v, 0));
  for (int i = 0; i <= n; i++) used[i] = false;
  used[v] = true;
  while (!q.empty()) {
    pair<int, int> t = q.front();
    q.pop();
    if (cycle[t.first]) return t.second;
    for (int i = 0; i < g[t.first].size(); i++)
      if (!used[g[t.first][i]]) {
        q.push(make_pair(g[t.first][i], t.second + 1));
        used[g[t.first][i]] = true;
      }
  }
}
int main() {
  scanf("%d", &n);
  g.assign(n + 1, vector<int>());
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &a, &b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(1, -1);
  for (int i = 1; i <= n; i++) cout << bfs(i) << ' ';
  return 0;
}
