#include <bits/stdc++.h>
void dfs(int32_t vertex, bool* visited, std::vector<int32_t>* graph,
         std::stack<int32_t>& cur_visited, int32_t parent,
         std::vector<int32_t>& cycle) {
  visited[vertex] = true;
  cur_visited.push(vertex);
  for (int32_t i = 0; i < graph[vertex].size(); i++)
    if (!visited[graph[vertex][i]])
      dfs(graph[vertex][i], visited, graph, cur_visited, vertex, cycle);
    else if (graph[vertex][i] != parent && cycle.size() == 0) {
      int32_t cur = vertex;
      while (cur != graph[vertex][i]) {
        cycle.push_back(cur);
        cur_visited.pop();
        cur = cur_visited.top();
      }
      cycle.push_back(graph[vertex][i]);
    }
  if (cur_visited.size() > 0) cur_visited.pop();
}
int main() {
  int32_t n;
  std::cin >> n;
  std::vector<int32_t>* graph = new std::vector<int32_t>[n];
  for (int32_t i = 0; i < n; i++) {
    int32_t src, dst;
    std::cin >> src >> dst;
    src--;
    dst--;
    graph[src].push_back(dst);
    graph[dst].push_back(src);
  }
  bool* visited = new bool[n];
  for (int32_t i = 0; i < n; i++) visited[i] = false;
  std::stack<int32_t> cur_visited;
  std::vector<int32_t> cycle;
  dfs(0, visited, graph, cur_visited, -1, cycle);
  int32_t* answer = new int32_t[n];
  for (int32_t i = 0; i < n; i++) visited[i] = false;
  std::queue<int32_t> bfs_queue;
  for (int32_t i = 0; i < cycle.size(); i++) {
    answer[cycle[i]] = 0;
    visited[cycle[i]] = true;
    bfs_queue.push(cycle[i]);
  }
  while (!bfs_queue.empty()) {
    int32_t cur = bfs_queue.front();
    bfs_queue.pop();
    for (int32_t i = 0; i < graph[cur].size(); i++)
      if (!visited[graph[cur][i]]) {
        visited[graph[cur][i]] = true;
        answer[graph[cur][i]] = answer[cur] + 1;
        bfs_queue.push(graph[cur][i]);
      }
  }
  for (int32_t i = 0; i < n; i++) std::cout << answer[i] << " ";
  return 0;
}
