#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long mod1 = 998244353;
const long long inf = 1e18;
const long long nax = 3005;
vector<long long> adj[nax];
long long indeg[nax], dist[nax], vis[nax], n, x, y;
set<long long> s;
void dfs(long long node, long long parent, long long d) {
  dist[node] = d;
  for (long long v : adj[node])
    if (v != parent && s.count(v) == 0) dfs(v, node, d + 1);
}
void kahn() {
  queue<long long> q;
  for (long long i = (1); i < (n + 1); i++)
    if (indeg[i] == 1) q.push(i);
  while (!q.empty()) {
    long long node = q.front();
    q.pop();
    vis[node] = 1;
    for (long long v : adj[node])
      if (!vis[v]) {
        indeg[v]--;
        if (indeg[v] == 1) q.push(v);
      }
  }
  for (long long i = (1); i < (n + 1); i++)
    if (!vis[i]) s.insert(i);
  for (long long u : s) dfs(u, -1, 0);
}
void solve() {
  cin >> n;
  for (long long i = (0); i < (n); i++) {
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
    indeg[x]++;
    indeg[y]++;
  }
  kahn();
  for (long long i = (1); i < (n + 1); i++) cout << dist[i] << " ";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
