#include <bits/stdc++.h>
using namespace std;
vector<int> graph[3002];
int visited[3002];
int level[3002];
int circular = 0;
void dfs(int start, int last) {
  int i, j;
  visited[start] = 1;
  int siz = graph[start].size();
  for (i = 0; i < siz; i++) {
    if (visited[graph[start][i]] == 0) {
      dfs(graph[start][i], start);
    } else {
      if (graph[start][i] == last) continue;
      if (visited[graph[start][i]] == 1) {
        circular = 100;
      }
    }
  }
  visited[start] = 2;
}
void bfs(int start) {
  queue<int> q;
  int i = 0;
  q.push(start);
  level[start] = 0;
  while (!q.empty()) {
    int temp = q.front();
    visited[temp] = 1;
    q.pop();
    int size = graph[temp].size();
    for (i = 0; i < size; i++) {
      if (visited[graph[temp][i]] == 0) {
        q.push(graph[temp][i]);
        level[graph[temp][i]] = min(level[temp] + 1, level[graph[temp][i]]);
      }
    }
  }
}
int hashi[3001];
int main() {
  memset(hashi, 0, sizeof(hashi));
  int i, j, t;
  int n;
  for (i = 1; i <= 3000; i++) {
    level[i] = 99999999LL;
    visited[i] = 0;
  }
  scanf("%d", &n);
  vector<pair<int, int> > v;
  for (i = 0; i < n; i++) {
    int st, en;
    scanf("%d%d", &st, &en);
    v.push_back(make_pair(st, en));
  }
  for (j = 0; j < n; j++) {
    for (i = 0; i <= 3000; i++) graph[i].clear();
    for (i = 0; i < n; i++) {
      if (i == j) continue;
      graph[v[i].second].push_back(v[i].first);
      graph[v[i].first].push_back(v[i].second);
    }
    circular = 0;
    memset(visited, 0, sizeof(visited));
    for (i = 1; i <= n; i++) {
      if (visited[i] == 0) dfs(i, -1);
    }
    if (circular == 0) {
      hashi[v[j].first]++;
      hashi[v[j].second]++;
    } else {
    }
  }
  for (i = 0; i <= 3000; i++) graph[i].clear();
  for (i = 0; i < n; i++) {
    graph[v[i].second].push_back(v[i].first);
    graph[v[i].first].push_back(v[i].second);
  }
  int ans[3001] = {0};
  for (i = 0; i <= n; i++)
    if (hashi[i] == 0) ans[i] = 99999999LL;
  for (i = 1; i <= n; i++) {
    for (int k = 0; k <= 3000; k++) {
      visited[k] = 0;
      level[k] = 99999999LL;
    }
    if (hashi[i] != 0) bfs(i);
    for (j = 1; j <= n; j++) {
      if (hashi[j] == 0) {
        ans[j] = min(ans[j], level[j]);
      }
    }
  }
  for (i = 1; i <= n; i++) printf("%d ", ans[i]);
  cout << endl;
  return 0;
}
