#include <bits/stdc++.h>
using namespace std;
long long int n;
vector<long long int> graph[3005];
vector<long long int> cycle;
long long int color[3005];
long long int pi[3005];
long long int d[3005];
void dfs_visit(long long int v) {
  color[v] = 1;
  for (long long int i = 0; i < graph[v].size(); i++) {
    long long int a = graph[v][i];
    if (color[a] == 0) {
      pi[a] = v;
      dfs_visit(a);
    } else if (color[a] == 1 && pi[v] != a) {
      long long int b = v;
      while (b != a) {
        cycle.push_back(b);
        b = pi[b];
      }
      cycle.push_back(a);
    }
  }
  color[v] = 2;
}
int main() {
  cin >> n;
  long long int x, y;
  for (long long int i = 1; i <= n; i++) {
    cin >> x >> y;
    graph[x].push_back(y);
    graph[y].push_back(x);
    color[i] = 0;
    d[i] = -1;
    pi[i] = -1;
  }
  for (long long int i = 1; i <= n; i++) {
    if (color[i] == 0) {
      dfs_visit(i);
    }
  }
  queue<long long int> q;
  for (long long int i = 0; i < cycle.size(); i++) {
    d[cycle[i]] = 0;
    q.push(cycle[i]);
  }
  while (!q.empty()) {
    long long int a = q.front();
    q.pop();
    for (long long int i = 0; i < graph[a].size(); i++) {
      long long int b = graph[a][i];
      if (d[b] == -1) {
        d[b] = d[a] + 1;
        q.push(b);
      }
    }
  }
  for (long long int i = 1; i <= n; i++) cout << d[i] << " ";
}
