#include <bits/stdc++.h>
using namespace std;
vector<long long> v[5000];
long long visited[5000];
long long visited2[5000];
set<long long> s;
struct dis {
  long long val = -1;
};
dis dist[5000];
map<long long, long long> mp;
bool dfs(long long child, long long parent) {
  visited[child] = 1;
  for (auto x : v[child]) {
    if (visited[x] == 1 && x != parent) {
      if (mp[x] >= 1) {
        return 0;
      }
      s.insert(x);
      mp[x]++;
      dist[x].val = 0;
      return 1;
    } else if (visited[x] == 1) {
      continue;
    }
    if (dfs(x, child)) {
      if (mp[x] >= 1) {
        break;
      }
      s.insert(x);
      mp[x]++;
      dist[x].val = 0;
      return 1;
    }
  }
  return 0;
}
void dfs2(long long child, long long parent) {
  visited2[child] = 1;
  for (auto x : v[child]) {
    if (x == parent || visited2[x] == 1) {
      continue;
    }
    if (dist[x].val == 0) {
      dfs2(x, child);
    } else {
      dist[x].val = dist[child].val + 1;
      dfs2(x, child);
    }
  }
}
signed main() {
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    long long a, b;
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  dfs(1, 0);
  long long first = 0;
  for (auto t : s) {
    first = t;
    break;
  }
  dfs2(first, 0);
  for (long long i = 1; i <= n; i++) {
    cout << dist[i].val << " ";
  }
  cout << "\n";
}
