#include <bits/stdc++.h>
const double PI = 3.1415926535897932384626433832795;
using namespace std;
long long mod = 1e9 + 7;
bool visited[3005];
vector<vector<int> > G;
bool cycle[3005];
int dp[3005], P[3005];
void dfs(int u, int v) {
  visited[u] = true;
  int sz = G[u].size();
  for (int i = 0; i < sz; ++i) {
    if (v == G[u][i]) continue;
    if (visited[G[u][i]] && !cycle[G[u][i]]) {
      cycle[G[u][i]] = true;
      for (int j = u; j != G[u][i]; j = P[j]) cycle[j] = true;
      break;
    }
    if (visited[G[u][i]]) continue;
    P[G[u][i]] = u;
    dfs(G[u][i], u);
  }
}
void dfs2(int u, int v, int len) {
  dp[u] = len;
  int sz = G[u].size();
  for (int i = 0; i < sz; ++i) {
    if (cycle[G[u][i]] || v == G[u][i]) continue;
    dfs2(G[u][i], u, len + 1);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(12);
  cout << fixed;
  int N, a, b;
  cin >> N;
  G.resize(N + 1);
  for (int i = 0; i < N; ++i) {
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  P[1] = 0;
  dfs(1, 0);
  for (int i = 1; i <= N; ++i)
    if (cycle[i]) dfs2(i, 0, 0);
  for (int i = 1; i <= N; ++i) cout << dp[i] << " ";
  cout << '\n';
  return 0;
}
