#include <bits/stdc++.h>
using namespace std;
int vis[3005] = {}, par[3005] = {}, dis[3005];
int flag = 0, parent = 0;
vector<int> adj[3005];
void dfs(int t) {
  for (int i = 0; i < adj[t].size(); i++) {
    if (!vis[adj[t][i]]) {
      vis[adj[t][i]] = 1;
      par[adj[t][i]] = t;
      dfs(adj[t][i]);
    } else if (flag == 0 && par[t] != adj[t][i]) {
      flag = t;
      parent = adj[t][i];
    }
  }
}
void dist(int t) {
  for (int i = 0; i < adj[t].size(); i++) {
    if (!vis[adj[t][i]]) {
      vis[adj[t][i]] = 1;
      if (dis[adj[t][i]] == -1) dis[adj[t][i]] = dis[t] + 1;
      dist(adj[t][i]);
    }
  }
}
int main() {
  int n, x, y;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  memset(dis, -1, sizeof(dis));
  dfs(1);
  dis[parent] = 0;
  while (flag != parent) {
    dis[flag] = 0;
    flag = par[flag];
  }
  memset(vis, 0, sizeof(vis));
  dist(parent);
  for (int i = 1; i <= n; i++) cout << dis[i] << " ";
  cout << endl;
  return 0;
}
