#include <bits/stdc++.h>
using namespace std;
void dfs(int x, int p, vector<vector<int>> &adj, vector<int> &vis,
         map<int, int> &cycle) {
  vis[x]++;
  if (vis[x] > 2) return;
  if (vis[x] == 2) {
    cycle[x]++;
    vis[p]++;
    return;
  }
  for (int i = 0; i < adj[x].size(); i++) {
    if (adj[x][i] != p) dfs(adj[x][i], x, adj, vis, cycle);
  }
  if (vis[x] == 2) {
    cycle[x]++;
    vis[p]++;
  }
}
void dfslength(int x, int p, int c, vector<vector<int>> &adj, vector<int> &ans,
               map<int, int> &cycle) {
  ans[x] = c;
  for (int i = 0; i < adj[x].size(); i++) {
    if (adj[x][i] != p && cycle[adj[x][i]] == 0)
      dfslength(adj[x][i], x, c + 1, adj, ans, cycle);
  }
}
int main() {
  int n;
  cin >> n;
  vector<vector<int>> adj;
  vector<int> vis(n + 1, 0);
  map<int, int> cycle;
  adj.resize(n + 1);
  for (int i = 0; i < n; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs(1, 0, adj, vis, cycle);
  vector<int> ans(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    if (cycle[i] > 0) dfslength(i, 0, 0, adj, ans, cycle);
  }
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
  return 0;
}
