#include <bits/stdc++.h>
using namespace std;
int LCA(int x, int y, vector<int>& ojciec) {
  stack<int> S1, S2;
  int ost;
  while (x != -1) {
    S1.push(x);
    x = ojciec[x];
  }
  while (y != -1) {
    S2.push(y);
    y = ojciec[y];
  }
  while (S1.top() == S2.top()) {
    ost = S1.top();
    S1.pop();
    S2.pop();
  }
  return ost;
}
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<vector<int> > T(n);
  int a, b;
  for (int i = 0; i < n; ++i) {
    cin >> a >> b;
    --a;
    --b;
    T[a].push_back(b);
    T[b].push_back(a);
  }
  vector<int> ojciec(n);
  ojciec[0] = -1;
  queue<int> Q;
  vector<bool> odw(n, false);
  int akt;
  vector<vector<bool> > rozp(n);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) rozp[i].push_back(false);
  Q.push(0);
  odw[0] = true;
  while (!Q.empty()) {
    akt = Q.front();
    Q.pop();
    for (int i = 0; i < T[akt].size(); ++i) {
      if (!odw[T[akt][i]]) {
        odw[T[akt][i]] = true;
        Q.push(T[akt][i]);
        ojciec[T[akt][i]] = akt;
        rozp[T[akt][i]][akt] = true;
        rozp[akt][T[akt][i]] = true;
      }
    }
  }
  int x, y;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < T[i].size(); ++j) {
      if (!rozp[i][T[i][j]]) {
        x = i;
        y = T[i][j];
      }
    }
  }
  for (int i = 0; i < n; ++i) odw[i] = false;
  int lca = LCA(x, y, ojciec);
  akt = x;
  while (akt != lca) {
    Q.push(akt);
    odw[akt] = true;
    akt = ojciec[akt];
  }
  akt = y;
  while (akt != lca) {
    Q.push(akt);
    odw[akt] = true;
    akt = ojciec[akt];
  }
  Q.push(lca);
  odw[lca] = true;
  vector<int> odl(n, 0);
  while (!Q.empty()) {
    akt = Q.front();
    Q.pop();
    for (int i = 0; i < T[akt].size(); ++i) {
      if (!odw[T[akt][i]]) {
        Q.push(T[akt][i]);
        odw[T[akt][i]] = true;
        odl[T[akt][i]] = odl[akt] + 1;
      }
    }
  }
  for (int i = 0; i < n; ++i) cout << odl[i] << " ";
  return 0;
}
