#include <bits/stdc++.h>
using namespace std;
int visited[3003];
vector<int> trace;
vector<int> cycle;
vector<int> graph[3003];
void dfs(int u, int prev) {
  trace.push_back(u);
  visited[u] = 1;
  for (int i = 0; i < graph[u].size(); ++i) {
    int v = graph[u][i];
    if (v != prev) {
      if (visited[v]) {
        for (int k = trace.size() - 1; k >= 0 && trace[k] != v; --k) {
          cycle.push_back(trace[k]);
        }
        cycle.push_back(v);
        return;
      } else {
        dfs(v, u);
        if (cycle.size() > 0) return;
      }
    }
  }
  visited[u] = 0;
  trace.pop_back();
}
int main() {
  int n;
  while (cin >> n) {
    memset(visited, 0, sizeof(visited));
    trace.clear();
    cycle.clear();
    for (int i = 0; i < n; ++i) graph[i].clear();
    for (int i = 0; i < n; ++i) {
      int u, v;
      cin >> u >> v;
      --u, --v;
      graph[u].push_back(v);
      graph[v].push_back(u);
    }
    dfs(0, -1);
    vector<int> dist(n);
    queue<int> q;
    memset(visited, 0, sizeof(visited));
    for (int i = 0; i < cycle.size(); ++i) {
      q.push(cycle[i]);
      visited[cycle[i]] = 1;
    }
    int d = 0;
    while (!q.empty()) {
      int cnt = q.size();
      for (int i = 0; i < cnt; ++i) {
        int curr = q.front();
        q.pop();
        dist[curr] = d;
        for (int k = 0; k < graph[curr].size(); ++k) {
          int u = graph[curr][k];
          if (!visited[u]) {
            q.push(u);
            visited[u] = 1;
          }
        }
      }
      ++d;
    }
    for (int i = 0; i < n; ++i) printf("%d ", dist[i]);
    puts("");
  }
  return 0;
}
