#include <bits/stdc++.h>
using namespace std;
vector<int> graf[5000];
int N;
int deg[5000];
int rodic[5000];
int D[5000];
bool bylo[5000];
queue<int> q;
bool nalezeno = false;
void dfs(int u, int p) {
  bylo[u] = 1;
  rodic[u] = p;
  for (int i = 0; i < graf[u].size(); i++) {
    if (bylo[graf[u][i]] == 0) {
      dfs(graf[u][i], u);
    } else if (graf[u][i] != p && nalezeno == false) {
      nalezeno = true;
      int v = u;
      q.push(v);
      D[v] = 1;
      while (v != graf[u][i]) {
        v = rodic[v];
        q.push(v);
        D[v] = 1;
      }
    }
  }
}
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--;
    b--;
    graf[a].push_back(b);
    graf[b].push_back(a);
    deg[a]++;
    deg[b]++;
  }
  int index = -1;
  for (int i = 0; i < N; i++)
    if (deg[i] == 1) {
      index = i;
      break;
    }
  if (index == -1) {
    for (int i = 0; i < N; i++) printf("0 ");
    printf("\n");
    return 0;
  }
  dfs(index, -1);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = 0; i < graf[u].size(); i++) {
      if (D[graf[u][i]] == 0) {
        D[graf[u][i]] = D[u] + 1;
        q.push(graf[u][i]);
      }
    }
  }
  for (int i = 0; i < N; i++) printf("%d ", D[i] - 1);
  printf("\n");
  return 0;
}
