#include <bits/stdc++.h>
using namespace std;
const int maxn = 4000;
vector<int> tree[maxn];
bool vis[maxn];
int deg[maxn], dis[maxn];
int n;
void bfs() {
  queue<int> q;
  for (int i = 1; i <= n; i++) {
    if (deg[i] == 1) q.push(i);
  }
  while (q.size()) {
    int v = q.front();
    q.pop();
    vis[v] = 1;
    for (int i = 0; i < tree[v].size(); i++) {
      int to = tree[v][i];
      if (!vis[to]) {
        deg[to]--;
        if (deg[to] < 2) q.push(to);
      }
    }
  }
}
void dfs(int u, int fa) {
  for (int i = 0; i < tree[u].size(); i++) {
    int v = tree[u][i];
    if (vis[v] && v != fa) {
      dis[v] = dis[u] + 1;
      dfs(v, u);
    }
  }
}
int main(void) {
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    int x, y;
    cin >> x >> y;
    tree[x].push_back(y);
    tree[y].push_back(x);
    deg[x]++;
    deg[y]++;
  }
  bfs();
  for (int i = 1; i <= n; i++)
    if (!vis[i]) dfs(i, -1);
  for (int i = 1; i <= n; i++) cout << dis[i] << " ";
  cout << endl;
  return 0;
}
