#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > g;
bitset<int(3e3)> visited;
vector<int> cyclicNodes;
vector<int> s;
int dis[int(3e3)];
void fillCN(int end) {
  while (s.back() != end) {
    cyclicNodes.push_back(s.back());
    s.pop_back();
  }
  cyclicNodes.push_back(end);
}
void dfs1(int u, int p) {
  visited[u] = true;
  s.push_back(u);
  for (int v : g[u]) {
    if (visited[v] && v != p && cyclicNodes.empty()) {
      fillCN(v);
      return;
    } else if (!visited[v])
      dfs1(v, u);
  }
  if (!s.empty()) s.pop_back();
}
void dfs2(int u, int p) {
  for (int v : g[u]) {
    if (v != p && dis[v] != 0) {
      dis[v] = 1 + dis[u];
      dfs2(v, u);
    }
  }
}
void solve(int n) {
  s.clear();
  cyclicNodes.clear();
  dfs1(0, 0);
  for (int u = 0; u < n; u++) dis[u] = 1e6;
  for (int u : cyclicNodes) dis[u] = 0;
  for (int u : cyclicNodes) dfs2(u, u);
  for (int u = 0; u < n; u++) cout << dis[u] << " ";
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  int u, v;
  cin >> n;
  g.assign(n, vector<int>());
  for (int _ = 0; _ < n; _++) {
    cin >> u >> v;
    u--, v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  solve(n);
}
