#include <bits/stdc++.h>
using namespace std;
int n;
int iirr[3000] = {0};
int vis[3000] = {0};
int d[3000] = {0};
vector<int> al[3000];
int t = 0;
void dfsv(int, int);
int pt = -1;
int dn = 0;
int findd(int);
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    al[u].push_back(v);
    al[v].push_back(u);
  }
  dfsv(0, -1);
  for (int i = 0; i < n; i++) {
    cout << findd(i) << " ";
  }
  return 0;
}
void dfsv(int v, int f) {
  d[v] = ++t;
  for (int i = 0; i < al[v].size(); i++) {
    if (d[al[v][i]] != 0 && al[v][i] != f) {
      pt = al[v][i];
      break;
    }
  }
  if (pt != -1) {
    iirr[v] = 1;
    return;
  }
  for (int i = 0; i < al[v].size(); i++) {
    if (d[al[v][i]] == 0) {
      dfsv(al[v][i], v);
      if (pt != -1) break;
    }
  }
  if (dn == 1) return;
  if (pt != -1) {
    iirr[v] = 1;
    if (v == pt) {
      dn = 1;
    }
    return;
  }
  ++t;
}
int findd(int v) {
  for (int i = 0; i < n; i++) vis[i] = -1;
  queue<int> q;
  q.push(v);
  vis[v] = 0;
  while (q.size() > 0) {
    int crnt = q.front();
    q.pop();
    if (iirr[crnt] == 1) {
      return vis[crnt];
    }
    for (int i = 0; i < al[crnt].size(); i++) {
      if (vis[al[crnt][i]] == -1) {
        vis[al[crnt][i]] = vis[crnt] + 1;
        q.push(al[crnt][i]);
      }
    }
  }
  return -1;
}
