#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e5 + 1, INF = 1e18 + 1;
long long i, j, k, n, m, answer, a[maxn], t, p[maxn], s;
vector<bool> used;
vector<long long> g[maxn];
queue<long long> q;
void dfs(long long x0, long long pr = -1) {
  long long i1, id, to;
  used[x0] = 1;
  for (i1 = 0; i1 < g[x0].size(); ++i1) {
    to = g[x0][i1];
    if (used[to] && to != pr) {
      s = x0;
      t = to;
      a[to] = 0;
      a[x0] = 0;
    }
    if (!used[to]) {
      p[to] = x0;
      dfs(to, x0);
    }
  }
}
int main() {
  cin >> n;
  for (i = 0; i < n; ++i) {
    cin >> j >> m;
    j--;
    m--;
    g[j].push_back(m);
    g[m].push_back(j);
  }
  used.assign(n, 0);
  dfs(0);
  i = t;
  used.assign(n, 0);
  while (i != s) {
    a[i] = 0;
    used[i] = 1;
    q.push(i);
    i = p[i];
  }
  a[s] = 0;
  used[s] = 1;
  q.push(s);
  while (q.size() > 0) {
    t = q.front();
    q.pop();
    for (i = 0; i < g[t].size(); ++i) {
      long long to = g[t][i];
      if (!used[to]) {
        a[to] = a[t] + 1;
        used[to] = 1;
        q.push(to);
      }
    }
  }
  for (i = 0; i < n; ++i) {
    cout << a[i] << " ";
  }
}
