#include <bits/stdc++.h>
using namespace std;
vector<int> vertex[3001];
int vertex_formed_cycle[3001], parent[3001], parent1[3001], n;
int dis_tance[3001];
bool visit[3001], visit2[3001];
int head = 0, fl;
void input() {
  int a, b;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a >> b;
    vertex[a].push_back(b);
    vertex[b].push_back(a);
  }
}
void find_cycle(int a, int flag) {
  visit[a] = true;
  for (int i = 0; i < vertex[a].size(); i++) {
    if (!visit[vertex[a][i]]) {
      parent[vertex[a][i]] = a;
      find_cycle(vertex[a][i], 0);
    } else {
      if (parent[a] != vertex[a][i]) {
        if (!fl) {
          head = vertex[a][i];
          fl = 1;
        }
        vertex_formed_cycle[a] = 1;
        if (a != head) vertex_formed_cycle[parent[a]] = 1;
        flag = 1;
      }
    }
  }
  if (vertex_formed_cycle[a] == 1) {
    if (a == head)
      ;
    else {
      vertex_formed_cycle[parent[a]] = 1;
    }
  }
}
void find_distance(int a) {
  visit2[a] = true;
  if (vertex_formed_cycle[a] == 1) {
    dis_tance[a] = 0;
  } else {
    dis_tance[a] = dis_tance[parent1[a]] + 1;
  }
  for (int i = 0; i < vertex[a].size(); i++) {
    if (!visit2[vertex[a][i]]) {
      parent1[vertex[a][i]] = a;
      find_distance(vertex[a][i]);
    }
  }
}
void dojob() {
  find_cycle(1, 0);
  find_distance(head);
  for (int i = 1; i <= n; i++) {
    cout << dis_tance[i] << " ";
  }
}
int main() {
  input();
  dojob();
}
