#include <bits/stdc++.h>
using namespace std;
const long long N = 3e3 + 10;
long long n, deg[N], mark[N], ans[N];
vector<long long> vec, adj[N];
queue<long long> que;
queue<pair<long long, long long> > q;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (long long i = 0; i < n; i++) {
    long long v, u;
    cin >> v >> u;
    v--;
    u--;
    adj[v].push_back(u);
    adj[u].push_back(v);
    deg[v]++;
    deg[u]++;
  }
  for (long long i = 0; i < n; i++)
    if (deg[i] == 1) que.push(i);
  while (que.size()) {
    long long v = que.front();
    que.pop();
    if (mark[v]) continue;
    mark[v] = 1;
    for (long long u : adj[v])
      if (!mark[u]) {
        deg[u]--;
        if (deg[u] == 1) que.push(u);
      }
  }
  for (long long i = 0; i < n; i++)
    if (!mark[i]) q.push({i, 0});
  memset(ans, 127, sizeof ans);
  while (q.size()) {
    long long v = q.front().first, c = q.front().second;
    q.pop();
    if (ans[v] < c) continue;
    ans[v] = c;
    for (long long u : adj[v])
      if (c + 1 < ans[u]) {
        ans[u] = c + 1;
        q.push({u, c + 1});
      }
  }
  for (long long i = 0; i < n; i++) cout << ans[i] << ' ';
}
