#include <bits/stdc++.h>
using namespace std;
void solve();
int main() {
  int t = 1;
  while (t--) solve();
  return 0;
}
long long n;
vector<long long> e[5000];
pair<long long, long long> edges[5000];
long long no;
bool be[5000];
long long pred[5000];
void dfs(long long v) {
  be[v] = true;
  for (long long i = 0; i < e[v].size(); i++)
    if (!be[e[v][i]] &&
        ((v != edges[no].first || e[v][i] != edges[no].second) &&
         (e[v][i] != edges[no].first || v != edges[no].second))) {
      dfs(e[v][i]);
      pred[e[v][i]] = v;
    }
}
vector<long long> cycle;
bool in[5000];
long long ans[5000];
long long d[5000];
long long bfs(long long v) {
  queue<long long> q;
  d[v] = 0;
  q.push(v);
  while (!q.empty()) {
    long long cur = q.front();
    q.pop();
    for (long long i = 0; i < e[cur].size(); i++)
      if (d[e[cur][i]] == -1) {
        if (in[e[cur][i]]) return d[cur] + 1;
        d[e[cur][i]] = d[cur] + 1;
        q.push(e[cur][i]);
      }
  }
}
void solve() {
  cin >> n;
  for (long long i = 0; i < n; i++) {
    long long q, w;
    cin >> q >> w;
    q--;
    w--;
    e[q].push_back(w);
    e[w].push_back(q);
    edges[i] = make_pair(q, w);
  }
  for (no = 0; no < n; no++) {
    memset(pred, -1, sizeof pred);
    memset(be, false, sizeof be);
    dfs(edges[no].first);
    if (be[edges[no].second]) {
      long long u = pred[edges[no].second];
      cycle.push_back(edges[no].second);
      while (u != -1) {
        cycle.push_back(u);
        u = pred[u];
      }
      break;
    }
  }
  for (long long i = 0; i < cycle.size(); i++) {
    in[cycle[i]] = true;
    ans[cycle[i]] = 0;
  }
  for (long long j = 0; j < n; j++)
    if (!in[j]) {
      memset(d, -1, sizeof d);
      ans[j] = bfs(j);
    }
  for (long long i = 0; i < n; i++) cout << ans[i] << ' ';
}
