#include <bits/stdc++.h>
using namespace std;
const int inf = 100000000;
int n, cf, ce;
vector<vector<int>> g;
vector<int> pred;
vector<char> used;
bool dfs(int s) {
  used[s] = 1;
  for (int i = 0; i < g[s].size(); ++i) {
    int to = g[s][i];
    if (pred[s] != to)
      if (used[to] == 0) {
        pred[to] = s;
        if (dfs(to)) return true;
      } else if (used[to] == 1) {
        ce = s;
        cf = to;
        return true;
      }
  }
  used[s] = 2;
  return false;
}
int main() {
  scanf("%d", &n);
  vector<int> d(n + 1, inf), md(n + 1, inf);
  g.resize(n + 1);
  pred.resize(n + 1);
  used.resize(n + 1);
  queue<int> q;
  vector<int> cycle;
  for (int i = 1; i <= n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for (int i = 0; i < n; ++i)
    if (dfs(i)) break;
  cycle.push_back(cf);
  for (int v = ce; v != cf; v = pred[v]) cycle.push_back(v);
  for (int j = 0; j < cycle.size(); j++) {
    int s = cycle[j];
    while (!q.empty()) q.pop();
    q.push(s);
    for (int i = 1; i <= n; i++) {
      used[i] = 0;
      d[i] = inf;
    }
    used[s] = 1;
    d[s] = 0;
    while (!q.empty()) {
      int v = q.front();
      q.pop();
      for (int i = 0; i < g[v].size(); i++) {
        int to = g[v][i];
        if (!used[to]) {
          used[to] = 1;
          q.push(to);
          d[to] = d[v] + 1;
        }
      }
    }
    for (int i = 1; i <= n; i++)
      if (d[i] < md[i]) md[i] = d[i];
  }
  for (int i = 1; i <= n; i++) printf("%d ", md[i]);
}
