#include <bits/stdc++.h>
using namespace std;
const int dl = 10069;
void bib() {
  for (int i = 0; i < (int)10; i++) {
    cout << "\a";
  }
}
const int M = 3000 + 10;
vector<int> adj[M];
vector<int> cycle;
int n;
bool seen[M];
int ans[M];
int dp[M];
int cyclest;
bool isinsycle(int x, int par = -1) {
  seen[x] = 1;
  for (int v : adj[x]) {
    if (!seen[v]) {
      if (isinsycle(v, x)) return 1;
    } else if (v != par)
      if (v == cyclest) return 1;
  }
  return 0;
}
void bfs(int x) {
  for (int i = 0; i < (int)n; i++) seen[i] = 0;
  dp[x] = 0;
  queue<int> q;
  q.push(x);
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    seen[v] = 1;
    for (int u : adj[v]) {
      if (seen[u]) continue;
      dp[u] = dp[v] + 1;
      q.push(u);
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < (int)n; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  for (int i = 0; i < (int)n; i++) ans[i] = M;
  for (int i = 0; i < (int)n; i++) {
    for (int j = 0; j < (int)n; j++) seen[j] = 0;
    cyclest = i;
    if (isinsycle(i)) cycle.push_back(i);
  }
  for (int t : cycle) {
    bfs(t);
    for (int i = 0; i < n; i++)
      if (dp[i] < ans[i]) ans[i] = dp[i];
  }
  for (int i = 0; i < n; i++) cout << ans[i] << " ";
  return 0;
}
