#include <bits/stdc++.h>
using namespace std;
long long parent[3001], dis[3001], vis[3001];
vector<long long> v[3001];
bool done(0);
void dfs(long long u, long long par) {
  if (done == 1) return;
  long long i;
  if (parent[u] >= 0) {
    i = par;
    while (i != u) {
      dis[i] = 0;
      i = parent[i];
    }
    dis[u] = 0;
    done = 1;
    return;
  }
  parent[u] = par;
  for (i = 0; i < v[u].size(); i++) {
    if (par != v[u][i]) dfs(v[u][i], u);
  }
  return;
}
void update(long long u, long long distance) {
  if (vis[u] == true) return;
  vis[u] = true;
  long long i;
  if (dis[u] == -1) dis[u] = distance;
  for (i = 0; i < v[u].size(); i++) {
    update(v[u][i], dis[u] + 1);
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  long long n, i;
  cin >> n;
  for (i = 1; i <= n; i++) dis[i] = -1;
  long long a, b;
  for (i = 1; i <= n; i++) {
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
    vis[i] = false;
    parent[i] = -1;
  }
  dfs(1, 0);
  for (i = 1; i <= n; i++) {
    if (dis[i] == 0) {
      update(i, 0);
      break;
    }
  }
  for (i = 1; i <= n; i++) cout << dis[i] << " ";
}
