#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1e18;
const long long int mxn = 3005;
vector<long long int> adj[mxn];
long long int color[mxn];
long long int par[mxn];
long long int dist[mxn];
void dfs(long long int u, long long int p) {
  if (color[u] == 2) return;
  if (color[u] == 1) {
    long long int cur = p;
    dist[cur] = 0;
    while (u != cur) {
      cur = par[cur];
      dist[cur] = 0;
    }
    color[u] = 2;
    return;
  }
  par[u] = p;
  color[u] = 1;
  for (long long int v : adj[u]) {
    if (v != p) dfs(v, u);
  }
  color[u] = 2;
}
void dfs2(long long int u, long long int p, long long int h) {
  dist[u] = h;
  for (long long int v : adj[u]) {
    if (v == p || dist[v] == 0) continue;
    dfs2(v, u, h + 1);
  }
}
inline void solve() {
  long long int n;
  cin >> n;
  for (long long int i = 1; i <= n; i++) {
    long long int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (long long int i = 1; i <= n; i++) dist[i] = -1, color[i] = 0;
  dfs(1, 0);
  for (long long int i = 1; i <= n; i++)
    if (dist[i] == 0) dfs2(i, 0, 0);
  for (long long int i = 1; i <= n; i++) cout << dist[i] << " ";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t = 1;
  while (t--) solve();
  return 0;
}
