#include <bits/stdc++.h>
using namespace std;
vector<int> graph[3001];
int d[3001], res, n;
int pre[3001], mark[3001];
void dfs(int v) {
  mark[v] = 1;
  for (int k = 0; k < graph[v].size(); ++k) {
    int j = graph[v][k];
    if (j != pre[v] && mark[j] && res == -1) {
      res = j;
      return;
    } else if (!mark[j]) {
      pre[j] = v;
      d[j] = d[v] + 1;
      if (res == -1) dfs(j);
    }
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    graph[a - 1].push_back(b - 1);
    graph[b - 1].push_back(a - 1);
  }
  for (int i = 0; i < n; ++i) {
    memset(mark, 0, sizeof(mark));
    memset(pre, -1, sizeof(pre));
    memset(d, 0, sizeof(d));
    res = -1;
    dfs(i);
    cout << d[res] << " ";
  }
  cout << endl;
  return 0;
}
