#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
int n, vis[N], par[N], dist[N];
vector<int> g[N], cycle;
void dfs(int node, int parent) {
  vis[node] = 1;
  vector<int>::iterator vit = g[node].begin();
  for (; vit != g[node].end(); vit++) {
    if (*vit != parent) {
      if (vis[*vit]) {
        int temp = *vit;
        int node_ = node;
        while (dist[temp] == -1 && par[node_] != temp) {
          dist[node_] = 0;
          node_ = par[node_];
        }
        dist[temp] = 0;
        dist[node_] = 0;
      } else {
        par[*vit] = node;
        dfs(*vit, node);
      }
    }
  }
}
void dfs2(int node) {
  vis[node] = 1;
  vector<int>::iterator vit = g[node].begin();
  for (; vit != g[node].end(); vit++) {
    if (!vis[*vit]) {
      if (dist[*vit] == -1) dist[*vit] = dist[node] + 1;
      dfs2(*vit);
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ;
  memset(dist, -1, sizeof dist);
  int i;
  cin >> n;
  for (i = 0; i < n; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  par[1] = -1;
  dfs(1, -1);
  memset(vis, 0, sizeof vis);
  for (i = 1; i <= n; i++) {
    if (!dist[i]) {
      break;
    }
  }
  dfs2(i);
  for (i = 1; i <= n; i++) {
    if (!dist[i]) {
      cout << 0 << " ";
    } else if (dist[i] == -1) {
      cout << dist[i] << " ";
    } else
      cout << dist[i] << " ";
  }
  return 0;
}
