#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const int N = 3e3 + 5;
const int INF = 2e9;
const lint LINF = 9e18;
int n;
int par[N], dist[N];
bool vis[N], cycle[N];
vector<int> adj[N];
void dfs(int u, int p = -1) {
  par[u] = p;
  vis[u] = 1;
  for (int v : adj[u]) {
    if (!vis[v]) {
      dfs(v, u);
    } else if (v != p && u > 1 && cycle[u] == 0) {
      int last = u;
      for (; last != v; last = par[last]) {
        cycle[last] = 1;
      }
      cycle[last] = 1;
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  fill(par + 1, par + n + 1, -1);
  dfs(1);
  fill(dist + 1, dist + n + 1, -1);
  const auto BFS = [&]() {
    queue<int> Q;
    for (int i = 1; i <= n; i++) {
      if (cycle[i]) {
        dist[i] = 0;
        Q.push(i);
      }
    }
    while (Q.size()) {
      int u = Q.front();
      Q.pop();
      for (int v : adj[u]) {
        if (dist[v] == -1) {
          dist[v] = dist[u] + 1;
          Q.push(v);
        }
      }
    }
  };
  BFS();
  for (int i = 1; i <= n; i++) {
    cout << dist[i] << (i == n ? "\n" : " ");
  }
}
