#include <bits/stdc++.h>
using namespace std;
vector<int> adj[3010];
int mark[3010];
int dis[3010];
int n, b, a;
bool found;
stack<int> st;
void dfs(int v, int par) {
  if (found) return;
  mark[v] = true;
  st.push(v);
  for (int i = 0; i < adj[v].size(); i++) {
    if (found) return;
    int u = adj[v][i];
    if (mark[u] == true) {
      if (u == par) continue;
      found = true;
      while (!st.empty()) {
        dis[st.top()] = 0;
        if (st.top() == u) break;
        st.pop();
      }
      return;
    } else
      dfs(u, v);
  }
  if (found) return;
  st.pop();
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  found = false;
  memset(dis, -1, sizeof dis);
  memset(mark, 0, sizeof mark);
  dfs(1, -1);
  queue<int> q;
  for (int i = 1; i <= n; i++)
    if (dis[i] == 0) q.push(i);
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (int i = 0; i < adj[v].size(); i++) {
      int u = adj[v][i];
      if (dis[u] == -1) dis[u] = dis[v] + 1, q.push(u);
    }
  }
  for (int i = 1; i <= n; i++) cout << (i == 1 ? "" : " ") << dis[i];
  cout << endl;
  return 0;
}
