#include <bits/stdc++.h>
using namespace std;
const int N = 3004;
int d[N], n, x, y;
vector<int> g[N];
queue<int> q;
int st[N], pos = 0;
bool vis[N];
bool dfs(int u, int f) {
  int v;
  vis[u] = 1;
  for (int i = 0; i < g[u].size(); i++) {
    v = g[u][i];
    if (f == v)
      continue;
    else if (vis[v]) {
      for (int i = pos; i >= 1 && st[i] != v; i--) {
        d[st[i]] = 0;
        q.push(st[i]);
      }
      d[v] = 0;
      q.push(v);
      return 1;
    } else {
      st[++pos] = v;
      if (dfs(v, u)) return 1;
      --pos;
    }
  }
  return 0;
}
int main() {
  memset(d, 0x3f, sizeof(d));
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &x, &y);
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(1, -1);
  while (!q.empty()) {
    x = q.front();
    q.pop();
    for (int i = 0; i < g[x].size(); i++) {
      y = g[x][i];
      if (d[y] != 0x3f3f3f3f) continue;
      d[y] = d[x] + 1;
      q.push(y);
    }
  }
  for (int i = 1; i <= n; i++) printf("%d%c", d[i], " \n"[i == n]);
}
