#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const int oo = 0x3f3f3f3f;
const long long ooLL = 0x3f3f3f3f3f3f3f3fLL;
int dist[3010];
bool visited[3010];
vector<vector<int> > g;
int cycle(int node, int parent) {
  visited[node] = true;
  for (int i = 0, (N) = static_cast<int>((g[node]).size()); i < N; ++i) {
    int j = g[node][i];
    if (j == parent) continue;
    if (visited[j]) {
      return j;
    }
    int start = cycle(j, node);
    if (start == -1) continue;
    if (start == -2) {
      visited[node] = false;
      return -2;
    }
    if (start == node) return -2;
    return start;
  }
  visited[node] = false;
  return -1;
}
void dfs(int node, int d, bool override = false) {
  if (!override && visited[node]) return;
  visited[node] = true;
  dist[node] = d;
  for (int i = 0, (N) = static_cast<int>((g[node]).size()); i < N; ++i) {
    int j = g[node][i];
    dfs(j, d + 1);
  }
}
int main() {
  int n;
  scanf("%d", &n);
  g.resize(n);
  for (int i = 0; i < n; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    --u;
    --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (int i = 0; i < n; ++i)
    if (cycle(i, -1)) {
      break;
    }
  for (int i = 0; i < n; ++i)
    if (dist[i] == 0 && visited[i]) dfs(i, 0, true);
  for (int i = 0; i < n; ++i) {
    if (i) printf(" ");
    printf("%d", dist[i]);
  }
  printf("\n");
  return 0;
}
