#include <bits/stdc++.h>
using namespace std;
vector<int> graph[3010];
int cycle[3010];
int cycle_size;
bool visited[3010];
bool found_cycle;
int dist[3010];
int b, e;
void dfs(int node, int father, int c) {
  if (found_cycle) return;
  visited[node] = true;
  for (int i = 0; i < graph[node].size() && !found_cycle; i++) {
    int nextn = graph[node][i];
    if (visited[nextn] && nextn != father) {
      cycle[c] = node;
      cycle_size = c + 1;
      while (cycle[c] != nextn) {
        c--;
      }
      b = c;
      found_cycle = true;
      return;
    }
    if (nextn == father) continue;
    cycle[c] = node;
    dfs(nextn, node, c + 1);
  }
}
void bfs() {
  queue<pair<int, int> > q;
  for (int i = b; i < cycle_size; i++) {
    visited[cycle[i]] = true;
    q.push(make_pair(cycle[i], 0));
  }
  while (!q.empty()) {
    pair<int, int> aux = q.front();
    q.pop();
    dist[aux.first] = aux.second;
    for (int i = 0; i < graph[aux.first].size(); i++) {
      int nextn = graph[aux.first][i];
      if (visited[nextn]) continue;
      visited[nextn] = true;
      q.push(make_pair(nextn, aux.second + 1));
    }
  }
}
int main() {
  int n;
  scanf("%d", &n);
  int xi, yi;
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &xi, &yi);
    graph[xi].push_back(yi);
    graph[yi].push_back(xi);
  }
  found_cycle = false;
  memset(visited, false, sizeof(visited));
  dfs(1, -1, 0);
  memset(visited, false, sizeof(visited));
  bfs();
  for (int i = 1; i <= n; i++) printf("%d ", dist[i]);
  printf("\n");
  return 0;
}
