#include <bits/stdc++.h>
using namespace std;
vector<int> vec[3010];
int in[3010];
int dist[3010];
const int INF = 2000000000;
int main() {
  int n, i, j, k, u, v, w;
  while (scanf("%d", &n) != EOF) {
    memset(in, 0, sizeof(in));
    for (i = 1; i <= n; i++) {
      vec[i].clear();
      dist[i] = INF;
    }
    for (i = 0; i < n; i++) {
      scanf("%d%d", &u, &v);
      vec[u].push_back(v);
      vec[v].push_back(u);
      in[u]++;
      in[v]++;
    }
    queue<int> que;
    for (i = 1; i <= n; i++) {
      if (in[i] == 1) que.push(i);
    }
    while (!que.empty()) {
      u = que.front();
      que.pop();
      for (i = 0; i < vec[u].size(); i++) {
        v = vec[u][i];
        in[v]--;
        if (in[v] == 1) que.push(v);
      }
    }
    queue<int> q;
    for (i = 1; i <= n; i++) {
      if (in[i] == 2) {
        dist[i] = 0;
        q.push(i);
      }
    }
    while (!q.empty()) {
      u = q.front();
      q.pop();
      for (i = 0; i < vec[u].size(); i++) {
        v = vec[u][i];
        if (dist[u] + 1 < dist[v]) {
          dist[v] = dist[u] + 1;
          q.push(v);
        }
      }
    }
    printf("%d", dist[1]);
    for (i = 2; i <= n; i++) printf(" %d", dist[i]);
    printf("\n");
  }
  return 0;
}
