#include <bits/stdc++.h>
using namespace std;
vector<int> v[3010], v1;
int vis[3010], dis[3010], path[3010], flag, len;
void dfs(int index, int par, int x) {
  if (vis[index] == 1) {
    flag = 1;
    path[x] = index;
    len = x;
    return;
  }
  path[x] = index;
  vis[index] = 1;
  for (int i = 0; i < v[index].size(); i++) {
    if (v[index][i] == par) continue;
    dfs(v[index][i], index, x + 1);
    if (flag == 1) return;
  }
  vis[index] = 0;
}
void dfs1(int index, int par, int dist) {
  dis[index] = dist;
  for (int i = 0; i < v[index].size(); i++) {
    if (dis[v[index][i]] == 0 || v[index][i] == par) continue;
    dfs1(v[index][i], index, dist + 1);
  }
}
int main() {
  int n, i, j, x, y;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &x);
    scanf("%d", &y);
    v[x].push_back(y);
    v[y].push_back(x);
  }
  for (i = 1; i <= n; i++) dis[i] = INT_MAX;
  for (i = 0; i < v[1].size(); i++) {
    vis[1] = 1;
    path[1] = 1;
    dfs(v[1][i], 1, 2);
    if (flag == 1) break;
  }
  for (i = 1; i <= len - 1; i++) {
    if (path[i] == path[len]) {
      j = i;
      break;
    }
  }
  for (i = j; i <= len - 1; i++) {
    dis[path[i]] = 0;
    v1.push_back(path[i]);
  }
  for (i = 0; i < v1.size(); i++) {
    dfs1(v1[i], -1, 0);
  }
  for (i = 1; i <= n; i++) {
    cout << dis[i] << " ";
  }
  cout << endl;
  return 0;
}
