#include <bits/stdc++.h>
using namespace std;
const int N = 3000 + 10;
vector<int> G[N], cycle;
bool mark[N];
int c = -1, d[N];
queue<int> q;
void DFS(int u, int par) {
  if (c != -1) return;
  if (mark[u]) {
    c = u;
    cycle.push_back(u);
    return;
  }
  mark[u] = true;
  cycle.push_back(u);
  for (int i = 0; i < int(G[u].size()); i++)
    if (G[u][i] != par) DFS(G[u][i], u);
  if (c != -1) return;
  cycle.resize(cycle.size() - 1);
}
void BFS(int u) {
  for (int i = u; i < int(cycle.size()); i++) {
    q.push(cycle[i]);
    mark[cycle[i]] = true;
  }
  while (q.size()) {
    int v = q.front();
    q.pop();
    for (int i = 0; i < int(G[v].size()); i++)
      if (!mark[G[v][i]]) {
        int s = G[v][i];
        mark[s] = true;
        q.push(s);
        d[s] = d[v] + 1;
      }
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int u, v;
    cin >> u >> v;
    G[--u].push_back(--v);
    G[v].push_back(u);
  }
  DFS(0, 0);
  for (int i = 0; i < n; i++) mark[i] = false;
  for (int i = 0; i < int(cycle.size()); i++)
    if (cycle[i] == cycle.back()) {
      BFS(i + 1);
      break;
    }
  for (int i = 0; i < n; i++) cout << d[i] << ' ';
}
