#include <bits/stdc++.h>
using namespace std;
long long cnt = 0, n;
long long final[200005];
set<long long> ans;
void dfs1(long long i, vector<long long> v[], bool visited[]) {
  if (i == 1)
    for (long long j = 1; j <= n; j++) visited[j] = false;
  visited[i] = true;
  cnt++;
  for (long long j = 0; j < v[i].size(); j++) {
    if (!visited[v[i][j]]) {
      dfs1(v[i][j], v, visited);
    }
  }
}
void dfs2(long long i, vector<long long> v[], bool visited[], long long h,
          long long temp) {
  if (i == temp)
    for (long long j = 1; j <= n; j++) visited[j] = false;
  visited[i] = true;
  final[i] = h;
  for (long long j = 0; j < v[i].size(); j++) {
    if (!visited[v[i][j]]) {
      if (ans.find(v[i][j]) != ans.end()) continue;
      dfs2(v[i][j], v, visited, h + 1, temp);
    }
  }
}
void solve() {
  cin >> n;
  vector<long long> v[n + 1];
  vector<pair<long long, long long>> edge(n + 1);
  bool visited[200005] = {false};
  for (long long i = 1; i <= n; i++) {
    long long x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
    edge[i].first = x;
    edge[i].second = y;
  }
  for (long long i = 1; i <= n; i++) {
    long long x = edge[i].first;
    long long y = edge[i].second;
    auto it1 = find(v[y].begin(), v[y].end(), x);
    v[y].erase(it1);
    auto it2 = find(v[x].begin(), v[x].end(), y);
    v[x].erase(it2);
    cnt = 0;
    dfs1(1, v, visited);
    if (cnt == n) {
      ans.insert(x);
      ans.insert(y);
    }
    v[x].push_back(y);
    v[y].push_back(x);
  }
  for (auto it : ans) {
    dfs2(it, v, visited, (long long)0, it);
  }
  for (auto it : ans) final[it] = 0;
  for (long long i = 1; i <= n; i++) cout << final[i] << " ";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  for (long long i = 0; i < t; i++) solve();
  return 0;
}
