#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> graph;
vector<int> parent;
bool found = false;
int v1, v2;
void visit(int v) {
  for (int node : graph[v])
    if (parent[v] != node && !found) {
      if (parent[node] == -1) {
        parent[node] = v;
        visit(node);
      } else {
        found = true;
        v1 = node;
        v2 = v;
      }
    }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  graph.resize(n + 1);
  parent.assign(n, -1);
  parent[0] = 0;
  for (int i = 0; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    graph[x].push_back(y);
    graph[y].push_back(x);
  }
  visit(0);
  set<int> ringroad;
  ringroad.insert(v2);
  int aux = v2;
  while (aux != v1) {
    aux = parent[aux];
    ringroad.insert(aux);
  }
  set<int> adj;
  for (int R : ringroad)
    for (int v : graph[R])
      if (!ringroad.count(v) && !adj.count(v)) {
        adj.insert(v);
        graph[n].push_back(v);
      }
  vector<int> dist(n + 1, INT_MAX);
  dist[n] = 0;
  for (int R : ringroad) dist[R] = 0;
  queue<int> lasagna;
  lasagna.push(n);
  while (!lasagna.empty()) {
    int v = lasagna.front();
    lasagna.pop();
    for (int node : graph[v])
      if (dist[v] + 1 < dist[node]) {
        dist[node] = dist[v] + 1;
        lasagna.push(node);
      }
  }
  for (int v = 0; v < n; ++v) cout << dist[v] << ' ';
  return 0;
}
