#include <bits/stdc++.h>
using namespace std;
int n, m, b[3001], book, b1[3001][3001];
vector<int> a[3001], p;
int find(int x) {
  for (int i = 0; i < p.size(); i++)
    if (p[i] == x) return i;
  return 0;
}
void dfs(int x) {
  if (book) return;
  for (int i = 0; i < a[x].size(); i++) {
    if (book) return;
    if (x == a[x][i] || b1[x][a[x][i]]) continue;
    int d = find(a[x][i]);
    if (d) {
      for (int j = d; j < p.size(); j++) b[p[j]] = 1;
      book = 1;
      return;
    }
    b1[a[x][i]][x] = 1;
    p.push_back(a[x][i]);
    dfs(a[x][i]);
    if (book) return;
    p.pop_back();
    b1[a[x][i]][x] = 0;
  }
}
struct point {
  int p, s;
  point(int pp, int ss) {
    p = pp;
    s = ss;
  }
};
int bfs(int x) {
  int b2[3001];
  memset(b2, 0, sizeof(b2));
  queue<point> q;
  q.push(point(x, 0));
  b2[x] = 1;
  while (!q.empty()) {
    point p = q.front();
    q.pop();
    if (b[p.p]) return p.s;
    for (int i = 0; i < a[p.p].size(); i++) {
      if (b2[a[p.p][i]]) continue;
      b2[a[p.p][i]] = 1;
      q.push(point(a[p.p][i], p.s + 1));
    }
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    a[x].push_back(y);
    a[y].push_back(x);
  }
  dfs(1);
  for (int i = 1; i <= n; i++) cout << bfs(i) << ' ';
  return 0;
}
