#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3000 + 10;
vector<int> A[MAXN];
bool Mark[MAXN];
int Dist[MAXN], RSTART;
void DFS(int v, int iDist) {
  Mark[v] = true;
  if (Dist[v] == -1) iDist = 0;
  Dist[v] = iDist;
  for (int i = 0; i < A[v].size(); ++i)
    if (!Mark[A[v][i]]) DFS(A[v][i], iDist + 1);
}
void DFS_FindCycle(int v, int f) {
  Mark[v] = true;
  int u;
  for (int i = 0; i < A[v].size() && !RSTART; ++i) {
    u = A[v][i];
    if (!Mark[u])
      DFS_FindCycle(u, v);
    else if (Mark[u] && u != f) {
      Dist[v] = -1;
      RSTART = u;
    }
  }
  if (Dist[u] == -1 && u != RSTART) Dist[v] = -1;
  Mark[v] = false;
}
int main() {
  int n, a, b;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a >> b;
    A[a].push_back(b);
    A[b].push_back(a);
  }
  DFS_FindCycle(1, 0);
  DFS(RSTART, 0);
  for (int i = 0; i < n; ++i) cout << Dist[i + 1] << " ";
  return 0;
}
