#include <bits/stdc++.h>
using namespace std;
struct node {
  int index;
  int len;
};
int main() {
  int x, y, n;
  scanf("%d", &n);
  vector<int> graph[n];
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &x, &y);
    graph[x - 1].push_back(y - 1);
    graph[y - 1].push_back(x - 1);
  }
  map<int, int> parent;
  map<int, bool> marked;
  bool visited[n];
  memset(visited, false, n);
  int rez[n];
  fill(rez, rez + n, INT_MAX);
  vector<int> cycle;
  stack<int> stek;
  stek.push(0);
  parent[0] = -1;
  while (!stek.empty()) {
    bool da = false;
    int top = stek.top();
    stek.pop();
    if (visited[top]) continue;
    visited[top] = true;
    for (int i = 0; i < graph[top].size(); i++) {
      int index = graph[top][i];
      if (!visited[index]) {
        stek.push(index);
        parent[index] = top;
      } else if (index != parent[top]) {
        cycle.push_back(top);
        marked[top] = true;
        int idx = parent[top];
        while (idx != index) {
          marked[idx] = true;
          cycle.push_back(idx);
          idx = parent[idx];
        }
        marked[index] = true;
        cycle.push_back(index);
        da = true;
        break;
      }
    }
    if (da) break;
  }
  for (int i = 0; i < cycle.size(); i++) {
    node temp, top;
    temp.len = 0;
    temp.index = cycle[i];
    memset(visited, false, n);
    visited[temp.index] = true;
    stack<node> s;
    s.push(temp);
    while (!s.empty()) {
      top = s.top();
      s.pop();
      rez[top.index] = top.len;
      temp.len = top.len + 1;
      for (int i = 0; i < graph[top.index].size(); i++) {
        temp.index = graph[top.index][i];
        if (!visited[temp.index] && !marked[temp.index]) {
          visited[temp.index] = 1;
          s.push(temp);
        }
      }
    }
  }
  for (int i = 0; i < n; i++) printf("%d ", rez[i]);
  return 0;
}
