#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
vector<int> vis2;
vector<bool> vis;
vector<vector<long long> > g;
int dis[3005] = {0};
bool incycle[3005] = {0};
int parent[3005] = {0};
void dfs2(int s, int &cyc) {
  vis2[s] = 1;
  for (auto child : g[s]) {
    if (child == parent[s]) continue;
    if (vis2[child] == 1) {
      int temp = s;
      cyc = child;
      while (temp != child) {
        incycle[temp] = true;
        temp = parent[temp];
      }
      incycle[child] = true;
    }
    if (vis2[child] == -1) {
      parent[child] = s;
      dfs2(child, cyc);
    }
  }
  vis2[s] = 2;
}
void dfs(int s, long long &d) {
  vis[s] = true;
  for (auto i : g[s]) {
    if (!vis[i]) {
      if (!incycle[i]) dis[i] = dis[s] + 1;
      dfs(i, d);
    }
  }
}
int main() {
  long long n, q;
  cin >> n;
  vis.assign(n + 1, false);
  vis2.assign(n + 1, -1);
  g.assign(n + 1, vector<long long>());
  q = n;
  while (q--) {
    long long x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  int cyc = 1;
  dfs2(1, cyc);
  long long d = 0;
  dfs(cyc, d);
  for (int i = 1; i <= n; i++) {
    if (!incycle[i])
      cout << dis[i] << " ";
    else
      cout << 0 << " ";
  }
  cout << '\n';
  return 0;
}
