#include <bits/stdc++.h>
using namespace std;
int n;
int dist[3005];
queue<int> q;
vector<int> v[3005];
vector<int> vis(3005);
int src;
int p[3005];
void dfs(int s, int par) {
  vis[s] = 1;
  for (int i = 0; i < v[s].size(); i++) {
    if (!vis[v[s][i]]) {
      p[v[s][i]] = s;
      dfs(v[s][i], s);
    } else {
      if (v[s][i] != par) {
        p[v[s][i]] = s;
        int tmp = v[s][i];
        while (1) {
          q.push(tmp);
          dist[tmp] = 0;
          tmp = p[tmp];
          if (tmp == v[s][i]) break;
        }
      }
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%d", &x);
    scanf("%d", &y);
    v[x].push_back(y);
    v[y].push_back(x);
  }
  fill(dist, dist + 3005, 1000000007);
  dfs(1, 0);
  fill(vis.begin(), vis.end(), 0);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    vis[u] = 1;
    for (int i = 0; i < v[u].size(); i++) {
      if (!vis[v[u][i]]) {
        if (dist[v[u][i]] > dist[u] + 1) {
          dist[v[u][i]] = dist[u] + 1;
          q.push(v[u][i]);
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) cout << dist[i] << " ";
  return 0;
}
