#include <bits/stdc++.h>
using namespace std;
vector<int> cycle;
vector<vector<int> > g;
int dist[30005];
bool visited[30005];
int p[30005];
void BFS(int s) {
  dist[s] = 0;
  queue<int> q;
  q.push(s);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    int d = dist[u];
    for (int i = 0; i < g[u].size(); i++) {
      int v = g[u][i];
      if (dist[v] > d + 1) {
        dist[v] = d + 1;
        q.push(v);
      }
    }
  }
}
bool getCycle(int n) {
  visited[n] = true;
  for (int i = 0; i < g[n].size(); i++) {
    int v = g[n][i];
    if (!visited[v] && v != p[n]) {
      p[v] = n;
      if (getCycle(v)) return true;
    } else if (v != p[n]) {
      int ver = n;
      while (ver != v) {
        cycle.push_back(ver);
        ver = p[ver];
      }
      cycle.push_back(v);
      return true;
    }
  }
  return false;
}
int main() {
  ios::sync_with_stdio(false);
  memset(dist, 1000000, sizeof(dist));
  int n;
  cin >> n;
  g.assign(n + 5, vector<int>());
  for (int i = 0; i < n; i++) {
    int t1, t2;
    cin >> t1 >> t2;
    g[t1].push_back(t2);
    g[t2].push_back(t1);
  }
  p[1] = 1;
  getCycle(1);
  for (int i = 0; i < cycle.size(); i++) {
    BFS(cycle[i]);
  }
  for (int i = 1; i < n; i++) cout << dist[i] << " ";
  cout << dist[n] << endl;
}
