#include <bits/stdc++.h>
using namespace std;
vector<int> A[3003];
int dist[3003], start;
void fill(int u, int p) {
  for (int i = 0; i < A[u].size(); i++) {
    int v = A[u][i];
    if (v == p) continue;
    if (dist[v] != 0) {
      dist[v] = dist[u] + 1;
      fill(v, u);
    }
  }
}
int dfs(int u, int p) {
  dist[u] = -1;
  for (int i = 0; i < A[u].size(); i++) {
    int v = A[u][i];
    if (v == p) continue;
    if (dist[v] == -1) {
      start = v;
      dist[u] = 0;
      return 1;
    } else {
      int ret = dfs(v, u);
      if (ret) {
        dist[u] = 0;
        return (u == start ? 0 : 1);
      }
    }
  }
  return 0;
}
int main() {
  int n, x, y;
  cin >> n;
  for (int i = 1; i < n + 1; i++) {
    dist[i] = -2;
    cin >> x >> y;
    A[x].push_back(y);
    A[y].push_back(x);
  }
  dfs(1, 0);
  for (int i = 1; i < n + 1; i++)
    if (dist[i] == 0) fill(i, 0);
  for (int i = 1; i < n + 1; i++) cout << dist[i] << " ";
}
