#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
const int inf = N * N;
vector<int> g[N];
int dist[N];
int vis[N];
int pr[N];
int lo = -1, hi = -1;
int n;
bool cycle_dfs(int u, int pru = 0) {
  vis[u] = 1;
  for (int v : g[u]) {
    if (v == pru) {
      continue;
    }
    if (vis[v] == 1) {
      lo = v, hi = u;
      return true;
    }
    if (!vis[v]) {
      pr[v] = u;
      if (cycle_dfs(v, u)) {
        return true;
      }
    }
  }
  vis[u] = 2;
  return false;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout.precision(15);
  cin >> n;
  for (int i = (0); i <= ((n)-1); i += (+1)) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (int u = (1); u <= ((n)); u += (+1)) {
    if (vis[u]) {
      continue;
    }
    if (cycle_dfs(u)) {
      break;
    }
  }
  for (int u = (1); u <= ((n)); u += (+1)) {
    dist[u] = inf;
  }
  queue<int> q;
  for (int u = hi; u != pr[lo]; u = pr[u]) {
    dist[u] = 0;
    q.push(u);
  }
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int v : g[u]) {
      if (dist[u] + 1 < dist[v]) {
        dist[v] = dist[u] + 1;
        q.push(v);
      }
    }
  }
  for (int u = (1); u <= ((n)); u += (+1)) {
    cout << dist[u] << " \n"[u == n];
  }
  return 0;
}
