#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/stack:60000000")
const int MN = 3000 + 10;
int dp[MN], vert = -1, n;
vector<int> sp, g[MN];
bool used[MN], open[MN], good = true;
void dfs(int v, bool need, int prev) {
  used[v] = open[v] = true;
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i];
    if (open[to] && to != prev) {
      if (vert == -1) vert = to;
      good = false;
      if (need) sp.push_back(v);
    }
    if (!used[to] && good) dfs(to, need, v);
    if (need && !good) sp.push_back(v);
  }
  open[v] = false;
}
queue<int> q;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(0, false, -1);
  fill(&used[0], &used[0] + MN, false);
  fill(&open[0], &open[0] + MN, false);
  fill(&dp[0], &dp[0] + MN, -1);
  good = true;
  dfs(vert, true, -1);
  for (int i = 0; i < sp.size(); i++) {
    dp[sp[i]] = 0;
    q.push(sp[i]);
  }
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (int i = 0; i < g[v].size(); i++) {
      int to = g[v][i];
      if (dp[to] == -1) {
        q.push(to);
        dp[to] = dp[v] + 1;
      }
    }
  }
  for (int i = 0; i < n; i++) cout << dp[i] << " ";
  return 0;
}
