#include <bits/stdc++.h>
using namespace std;
int n, head[3010], nxt[2 * 3010], to[2 * 3010], cnt, d[3010], root = -1;
bool used[3010];
void add(int u, int v) {
  to[cnt] = v;
  nxt[cnt] = head[u];
  head[u] = cnt++;
}
bool find_cycle(int u, int p = -1) {
  if (u == root) return false;
  if (used[u]) {
    if (root != -1) return false;
    root = u;
    d[u] = 0;
    return true;
  }
  used[u] = true;
  bool on_cycle = false;
  for (int i = head[u]; i != -1; i = nxt[i])
    if (to[i] != p) on_cycle |= find_cycle(to[i], u);
  if (on_cycle) d[u] = 0;
  return on_cycle && u != root;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) head[i] = d[i] = -1;
  for (int i = 0; i < n; ++i) {
    int u, v;
    cin >> u >> v;
    --u;
    --v;
    add(u, v);
    add(v, u);
  }
  find_cycle(0);
  queue<int> q;
  for (int i = 0; i < n; ++i)
    if (!d[i]) q.push(i);
  while (!q.empty()) {
    int cur = q.front();
    q.pop();
    for (int i = head[cur]; i != -1; i = nxt[i])
      if (d[to[i]] == -1) {
        d[to[i]] = d[cur] + 1;
        q.push(to[i]);
      }
  }
  for (int i = 0; i < n; ++i) cout << d[i] << " ";
  return 0;
}
