#include <bits/stdc++.h>
using namespace std;
vector<int> arr[3010];
int vis[3010];
bool incycle[3010];
int ans[3010];
void dfscycle(int s, int prev) {
  vis[s] = -1;
  int o = arr[s].size();
  for (int i = 0; i < o; ++i) {
    int to = arr[s][i];
    if (to == prev) continue;
    if (vis[to] == 1)
      continue;
    else if (vis[to] == -1) {
      incycle[to] = 1;
      return;
    } else
      dfscycle(to, s);
  }
  vis[s] = 1;
}
void dfs(int s, int cnt) {
  vis[s] = 1;
  ans[s] = cnt;
  int o = arr[s].size();
  for (int i = 0; i < o; ++i) {
    int to = arr[s][i];
    if (!vis[to] && !incycle[to]) dfs(to, cnt + 1);
  }
}
int main() {
  int n, u, v;
  scanf("%d", &n);
  ;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &u);
    ;
    scanf("%d", &v);
    ;
    arr[u].push_back(v);
    arr[v].push_back(u);
  }
  for (int i = 1; i <= n; ++i) {
    memset(vis, 0, sizeof(vis));
    dfscycle(i, 0);
  }
  for (int i = 1; i <= n; ++i) ans[i] = 1e8;
  for (int i = 1; i <= n; ++i) {
    if (incycle[i]) {
      memset(vis, 0, sizeof(vis));
      dfs(i, 0);
    }
  }
  for (int i = 1; i <= n; ++i) printf("%d ", ans[i]);
  printf("\n");
}
