#include <bits/stdc++.h>
using namespace std;
const double EPS = 1E-9;
const int INF = 1000000000;
const long long INF64 = (long long)1E18;
const double PI = 3.1415926535897932384626433832795;
vector<int> ad_list[3005];
int dfs_num[3005], dfs_low[3005];
bool isVISIT[3005];
int parent[3005];
int low_dist[3005];
bool is_incycle[3005];
int n;
int root;
int dfs_count = 0;
void DFS(int u) {
  dfs_num[u] = dfs_low[u] = ++dfs_count;
  isVISIT[u] = true;
  for (int i = 0; i < (int)ad_list[u].size(); i++) {
    int v = ad_list[u][i];
    if (!isVISIT[v]) {
      parent[v] = u;
      DFS(v);
      if (is_incycle[v] && dfs_num[u] >= dfs_num[root]) is_incycle[u] = true;
    } else if (parent[u] != v) {
      is_incycle[u] = true;
      root = v;
    }
  }
}
void ini() {
  memset(parent, 0, sizeof(parent));
  for (int i = 0; i <= n; i++) low_dist[i] = -1;
}
int main() {
  ini();
  cin >> n;
  int u, v;
  for (int i = 0; i < (int)(n); i++) {
    cin >> u >> v;
    ad_list[u].push_back(v);
    ad_list[v].push_back(u);
  }
  DFS(1);
  queue<int> q;
  memset(isVISIT, 0, sizeof(isVISIT));
  for (int i = 1; i <= n; i++)
    if (is_incycle[i]) {
      low_dist[i] = 0;
      q.push(i);
      isVISIT[i] = true;
    }
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = 0; i < (int)ad_list[u].size(); i++) {
      int v = ad_list[u][i];
      if (!isVISIT[v]) {
        isVISIT[v] = true;
        low_dist[v] = low_dist[u] + 1;
        q.push(v);
      }
    }
  }
  for (int i = 1; i <= n; i++) cout << low_dist[i] << " ";
}
