#include <bits/stdc++.h>
using namespace std;
const int inf = 1e+9;
int n, flag = 0;
vector<vector<int> > g;
vector<int> dist, used;
deque<int> k;
void dfs(int v, int from = -1) {
  used[v] = 1;
  for (int to : g[v]) {
    if (!used[to]) {
      k.push_back(to);
      dfs(to, v);
      k.pop_back();
    } else {
      if (from != to && !flag) {
        int j = k.size() - 1;
        while (k[j] != to) {
          dist[k[j]] = 0;
          j--;
        }
        dist[to] = 0;
        dist[v] = 0;
        flag = 1;
      }
    }
  }
}
int main() {
  cin >> n;
  dist.resize(n, inf);
  used.resize(n);
  g.resize(n);
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    g[a - 1].push_back(b - 1);
    g[b - 1].push_back(a - 1);
  }
  k.push_back(0);
  dfs(0);
  used.assign(n, 0);
  deque<int> q;
  for (int i = 0; i < n; i++) {
    if (dist[i] == 0) {
      used[i] = 1;
      q.push_back(i);
    }
  }
  while (!q.empty()) {
    int v = q.back();
    q.pop_back();
    for (int to : g[v]) {
      if (!used[to]) {
        q.push_back(to);
        used[to] = 1;
        dist[to] = dist[v] + 1;
      }
    }
  }
  for (int i : dist) {
    cout << i << ' ';
  }
}
