#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > a;
int a1 = 0;
bool v[3005];
int b[3005];
void dfs(int x, int p) {
  v[x] = 1;
  for (int i = 0; i < a[x].size(); i++) {
    if (a[x][i] == p) continue;
    if (v[a[x][i]]) {
      a1 = x;
    } else {
      dfs(a[x][i], x);
    }
  }
}
bool go(int x, int p) {
  if (v[x]) return true;
  v[x] = 1;
  for (int i = 0; i < a[x].size(); i++) {
    if (a[x][i] == p) continue;
    if (go(a[x][i], x)) {
      b[x] = 0;
      return true;
    }
  }
  return false;
}
int go2(int x, int p) {
  if (v[x]) return b[x];
  v[x] = 1;
  if (b[x] == 0) return 0;
  for (int i = 0; i < a[x].size(); i++) {
    if (a[x][i] == p) continue;
    b[x] = min(b[x], go2(a[x][i], x) + 1);
  }
  if (b[x] > 1e7) v[x] = 0;
  return b[x];
}
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  a.resize(n + 1);
  for (int i = 0; i < n; i++) {
    int u, v;
    cin >> u >> v;
    a[u].push_back(v);
    a[v].push_back(u);
  }
  dfs(1, 0);
  for (int i = 1; i <= n; i++) {
    b[i] = 1e9;
  }
  memset(v, 0, sizeof(v));
  go(a1, 0);
  memset(v, 0, sizeof(v));
  for (int i = 1; i <= n; i++) {
    if (!v[i]) go2(i, 0);
  }
  for (int i = 1; i <= n; i++) {
    cout << b[i] << " ";
  }
  cout << endl;
  return 0;
}
