#include <bits/stdc++.h>
using namespace std;
struct node {
  vector<int> k;
  int col;
  bool u;
  int res;
  node() {
    col = 0;
    k.clear();
    u = false;
    res = 0;
  }
};
vector<node> a;
int ex, n;
void find_cycle(int u) {
  int t = 0;
  a[u].u = true;
  for (int i = 0; i < a[u].k.size(); i++) {
    if (a[a[u].k[i]].u)
      t++;
    else
      find_cycle(a[u].k[i]);
  }
  if (t > 1) ex = u;
}
int extract_cycle(int u, int p) {
  a[u].col = 1;
  for (int i = 0; i < a[u].k.size(); i++) {
    if (a[u].k[i] != p) {
      if (a[a[u].k[i]].col == 1) return 0;
      if (a[a[u].k[i]].col == 0)
        if (!extract_cycle(a[u].k[i], u)) return 0;
    }
  }
  a[u].col = 2;
  return 1;
}
void get_dist(int d, int u) {
  a[u].u = true;
  a[u].res = d;
  for (int i = 0; i < a[u].k.size(); i++) {
    if (!a[a[u].k[i]].u)
      if (a[a[u].k[i]].col == 1)
        get_dist(0, a[u].k[i]);
      else
        get_dist(d + 1, a[u].k[i]);
  }
}
int main() {
  cin >> n;
  int x, y;
  a.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    x--;
    y--;
    a[x].k.push_back(y);
    a[y].k.push_back(x);
  }
  find_cycle(0);
  extract_cycle(ex, -1);
  for (int i = 0; i < n; a[i].u = false, i++)
    ;
  get_dist(0, ex);
  for (int i = 0; i < n; i++) cout << a[i].res << ' ';
}
