#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int scr, des, ans;
vector<int> path;
int lev[3001];
void DFS(int u, vector<int> adj[], vector<bool> &visited, int par) {
  visited[u] = true;
  v.push_back(u);
  for (int i = 0; i < adj[u].size(); i++)
    if (visited[adj[u][i]] == false) {
      DFS(adj[u][i], adj, visited, u);
      if (scr != 0) return;
    } else if (visited[adj[u][i]] == true && adj[u][i] != par) {
      scr = u;
      des = adj[u][i];
      return;
    }
}
void DFS2(int s, int d, vector<int> adj[], vector<bool> &vis) {
  vis[s] = true;
  path.push_back(s);
  if (s == d) {
    ans = 1;
    return;
  }
  for (int i = 0; i < adj[s].size(); i++) {
    if (!vis[adj[s][i]] && (path.size() > 1 || adj[s][i] != d)) {
      DFS2(adj[s][i], d, adj, vis);
      if (ans == 1) return;
    }
  }
  path.pop_back();
  vis[s] = false;
}
void DFS3(int u, vector<int> adj[], vector<bool> &visited) {
  visited[u] = true;
  for (int i = 0; i < adj[u].size(); i++)
    if (visited[adj[u][i]] == false) {
      lev[adj[u][i]] = lev[u] + 1;
      DFS3(adj[u][i], adj, visited);
    }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  while (t--) {
    int n;
    cin >> n;
    vector<int> adj[n + 1];
    for (long long i = 0; i < n; i++) {
      int a, b;
      cin >> a >> b;
      adj[a].push_back(b);
      adj[b].push_back(a);
    }
    vector<bool> vis(n + 1, false);
    DFS(1, adj, vis, -1);
    vector<bool> vis2(n + 1, false);
    DFS2(scr, des, adj, vis2);
    vector<bool> vis3(n + 1, false);
    for (long long i = 0; i < path.size(); i++) vis3[path[i]] = true;
    for (long long i = 0; i < path.size(); i++) {
      vis3[path[i]] = false;
      lev[path[i]] = 0;
      DFS3(path[i], adj, vis3);
    }
    for (long long i = 1; i <= n; i++) cout << lev[i] << " ";
  }
}
