#include <bits/stdc++.h>
using namespace std;
vector<int> g[30010];
char vis[30010], cycle[30010];
int dist[30010];
bool achei = false;
int n;
stack<int> p;
void dfs(int u, int lst) {
  if (achei) return;
  if (vis[u]) {
    while (p.top() != u) {
      cycle[p.top()] = 1;
      p.pop();
    }
    cycle[u] = 1;
    p.pop();
    achei = true;
    return;
  }
  vis[u] = 1;
  p.push(u);
  for (int v : g[u])
    if (v != lst) dfs(v, u);
  if (achei) return;
  p.pop();
}
void bfs() {
  queue<int> q;
  for (int i = 0; i <= n; i++) {
    dist[i] = 101010;
    if (cycle[i]) {
      dist[i] = 0;
      q.push(i);
    }
  }
  int u;
  while (!q.empty()) {
    u = q.front();
    q.pop();
    for (int v : g[u]) {
      if (dist[u] + 1 < dist[v]) {
        dist[v] = dist[u] + 1;
        q.push(v);
      }
    }
  }
}
int main() {
  int u, v;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(1, 1);
  bfs();
  for (int i = 1; i <= n; i++) {
    if (cycle[i])
      cout << "0 ";
    else
      cout << dist[i] << " ";
  }
  cout << "\n";
  return 0;
}
