#include <bits/stdc++.h>
using namespace std;
using lli = long long;
using ld = long double;
mt19937 rnd(time(nullptr));
enum Enm { White, Gray, Black };
const int inf = 1e9;
int n = 0;
vector<vector<int>> data;
vector<int> colors;
vector<int> order;
vector<int> dist;
bool DFS(int v, int p) {
  if (colors[v] == Gray) {
    dist[v] = 0;
    while (!order.empty()) {
      if (order.back() == v) break;
      dist[order.back()] = 0;
      order.pop_back();
    }
    return true;
  }
  if (colors[v] == Black) return false;
  colors[v] = Gray;
  order.push_back(v);
  for (int u : data[v]) {
    if (u != p) {
      if (DFS(u, v)) return true;
    }
  }
  colors[v] = Black;
  order.pop_back();
  return false;
}
void BFS() {
  queue<int> q;
  for (int i = 0; i < n; i++)
    if (dist[i] == 0) q.push(i);
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (int u : data[v]) {
      if (dist[u] > dist[v] + 1) {
        dist[u] = dist[v] + 1;
        q.push(u);
      }
    }
  }
}
inline void Solve() {
  cin >> n;
  data.resize(n);
  colors.resize(n, White);
  dist.resize(n, inf);
  for (int i = 0; i < n; i++) {
    int a = 0, b = 0;
    cin >> a >> b;
    a--, b--;
    data[a].push_back(b);
    data[b].push_back(a);
  }
  DFS(0, -1);
  BFS();
  for (int i = 0; i < n; i++) cout << dist[i] << ' ';
}
signed main() {
  cout << fixed << setprecision(20);
  Solve();
  return 0;
}
