#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > g;
vector<int> ckl;
vector<int> p;
int n, cend, start;
bool dfs(int v) {
  ckl[v] = 1;
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i];
    if (ckl[to] == 0) {
      p[to] = v;
      if (dfs(to)) return true;
    } else if (ckl[to] == 1 && p[v] != to) {
      p[to] = v;
      cend = v;
      start = to;
      return true;
    }
  }
  ckl[v] = 2;
  return false;
}
int main() {
  cin >> n;
  g.resize(n);
  ckl.assign(n, 0);
  p.assign(n, -1);
  start = -1;
  for (int i = 0; i < n; i++) {
    int as, bs;
    cin >> as >> bs;
    g[as - 1].push_back(bs - 1);
    g[bs - 1].push_back(as - 1);
  }
  for (int i = 0; i < n; i++) {
    if (dfs(i)) break;
  }
  queue<int> q;
  vector<int> way(n, -1);
  q.push(cend);
  way[cend] = 0;
  for (int i = p[cend]; i != cend; i = p[i]) {
    q.push(i);
    way[i] = 0;
  }
  while (!q.empty()) {
    int k = q.front();
    q.pop();
    for (int i = 0; i < g[k].size(); i++) {
      int to = g[k][i];
      if (way[to] == -1) {
        way[to] = way[k] + 1;
        q.push(to);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << way[i] << " ";
  }
  return 0;
}
