#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> v;
const int MAXN = 3000 + 1;
bool cycle[MAXN];
bool vis[MAXN];
int res[MAXN];
void dfs(int node, int parent, int src) {
  if (vis[node] && node == src) {
    cycle[node] = true;
    return;
  } else if (vis[node])
    return;
  vis[node] = true;
  for (int i = 0; i < v[node].size(); ++i)
    if (v[node][i] != parent) dfs(v[node][i], node, src);
}
int dfs2(int node, int cost) {
  if (vis[node]) return -1;
  if (cycle[node]) {
    return cost;
  }
  vis[node] = true;
  for (int i = 0; i < v[node].size(); ++i) {
    int val = dfs2(v[node][i], cost + 1);
    if (val != -1) return val;
  }
  return -1;
}
int main() {
  int n;
  scanf("%d", &n);
  v.resize(n, vector<int>());
  for (int i = 0, a, b; i < n; ++i) {
    scanf("%d%d", &a, &b);
    --a;
    --b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  for (int i = 0; i < n; ++i) {
    memset(vis, false, sizeof(vis));
    dfs(i, -1, i);
  }
  for (int i = 0; i < n; ++i) {
    memset(vis, false, sizeof(vis));
    if (cycle[i]) continue;
    int vals = dfs2(i, 0);
    res[i] = vals;
  }
  for (int i = 0; i < n; ++i) printf("%d ", res[i]);
  puts("");
  return 0;
}
