#include <bits/stdc++.h>
using namespace std;
struct Vertex {
  int dist, parent, time_in, min_time;
  bool visit;
  vector<int> sosedi;
};
vector<Vertex> graph;
int timer = 0;
int min(int a, int b) {
  if (a <= b)
    return a;
  else
    return b;
}
void dfs1(int v, int parent = -1) {
  timer++;
  graph[v].time_in = graph[v].min_time = timer;
  graph[v].visit = true;
  for (int i = 0; i < graph[v].sosedi.size(); i++) {
    if (graph[v].sosedi[i] != parent) {
      if (!graph[graph[v].sosedi[i]].visit) {
        dfs1(graph[v].sosedi[i], v);
        graph[v].min_time =
            min(graph[v].min_time, graph[graph[v].sosedi[i]].min_time);
        if (graph[graph[v].sosedi[i]].min_time <= graph[v].time_in) {
          graph[v].dist = 0;
          graph[graph[v].sosedi[i]].dist = 0;
        }
      } else
        graph[v].min_time =
            min(graph[v].min_time, graph[graph[v].sosedi[i]].time_in);
    }
  }
}
void dfs(int v, int parent) {
  graph[v].dist = graph[parent].dist + 1;
  for (int i = 0; i < graph[v].sosedi.size(); i++) {
    if (graph[v].sosedi[i] != parent) dfs(graph[v].sosedi[i], v);
  }
}
int main() {
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  graph.resize(n);
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    graph[a - 1].sosedi.push_back(b - 1);
    graph[b - 1].sosedi.push_back(a - 1);
  }
  for (int i = 0; i < n; i++) {
    graph[i].visit = false;
    graph[i].dist = n + 1;
  }
  dfs1(0);
  for (int i = 0; i < n; i++) {
    if (graph[i].dist == 0) {
      for (int j = 0; j < graph[i].sosedi.size(); j++) {
        if (graph[graph[i].sosedi[j]].dist == n + 1) dfs(graph[i].sosedi[j], i);
      }
    }
  }
  for (int i = 0; i < n; i++) cout << graph[i].dist << " ";
  return 0;
}
