#include <bits/stdc++.h>
using namespace std;
class node {
 public:
  vector<int> edges;
  int dist = 99999;
  int color = 0;
  bool visited = 0;
};
vector<node> a;
int f = 0, z = -1;
void dfs(long long i, long long p) {
  if (a[i].color == 1 && f == 0) {
    z = i;
    f = 1;
  }
  if (f == 1) return;
  a[i].color = 1;
  for (int j : a[i].edges)
    if (j != p) dfs(j, i);
  if (f == 1) {
    if (i == z) f = 0;
    return;
  }
  a[i].color = 2;
  return;
}
void ass_dist(int i, int l) {
  if (a[i].visited) return;
  a[i].visited = 1;
  a[i].dist = min(a[i].dist, l);
  for (int j : a[i].edges) ass_dist(j, a[i].dist + 1);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; i++) {
    int p, q;
    cin >> p >> q;
    a[p - 1].edges.push_back(q - 1);
    a[q - 1].edges.push_back(p - 1);
  }
  dfs(0, -1);
  for (int i = 0; i < n; i++)
    if (a[i].color == 1) a[i].dist = 0;
  int k;
  while (a[k].color != 1) k++;
  ass_dist(k, 0);
  for (int i = 0; i < n; i++) cout << a[i].dist << " ";
  return 0;
}
