#include <bits/stdc++.h>
using namespace std;
const long long int C = 1e9 + 7;
long long int fact(int n) {
  if (n >= 1)
    return n * fact(n - 1) % C;
  else
    return 1;
}
long long int prime(long long int n) {
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) return 1;
  }
  return 0;
}
void dfs(int u, vector<int> &vi, vector<vector<int>> &adj, int p,
         map<int, int> &cyc) {
  vi[u]++;
  if (vi[u] > 2) return;
  if (vi[u] == 2) {
    cyc[u]++;
    vi[p]++;
    return;
  }
  for (auto x : adj[u]) {
    if (x != p) dfs(x, vi, adj, u, cyc);
  }
  if (vi[u] == 2) {
    cyc[u]++;
    vi[p]++;
    return;
  }
}
void dfsbranch(int u, vector<vector<int>> &adj, int p, map<int, int> &cyc,
               vector<int> &ans, int cou) {
  ans[u] = cou;
  for (auto x : adj[u]) {
    if (x != p && cyc[x] == 0) dfsbranch(x, adj, u, cyc, ans, cou + 1);
  }
}
void solve() {
  int n;
  cin >> n;
  vector<vector<int>> adj;
  int x, y;
  adj.resize(n + 1);
  for (int i = 0; i < (int)n; i++) {
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  vector<int> vi(n + 1, 0);
  map<int, int> cyc;
  dfs(1, vi, adj, 0, cyc);
  vector<int> ans(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    if (cyc[i] != 0) dfsbranch(i, adj, 0, cyc, ans, 0);
  }
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
