#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > Graph;
vector<bool> IsVisited;
vector<int> Distances;
vector<int> Prev;
queue<int> Queue;
vector<bool> IsVisited2;
bool CycleFound = false;
void dfs(int v) {
  IsVisited[v] = true;
  for (int& i : Graph[v]) {
    if (CycleFound) {
      return;
    }
    if (!IsVisited[i]) {
      Prev[i] = v;
      dfs(i);
    } else if (Prev[v] != i) {
      CycleFound = true;
      int k = v;
      while (k != i) {
        Distances[k] = 0;
        Queue.push(k);
        IsVisited2[k] = true;
        k = Prev[k];
      }
      Queue.push(i);
      Distances[i] = 0;
      IsVisited2[i] = true;
    }
  }
}
int main() {
  int N;
  cin >> N;
  Graph.resize(N);
  IsVisited.resize(N, false);
  IsVisited2.resize(N, false);
  Distances.resize(N);
  Prev.resize(N);
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    Graph[a - 1].push_back(b - 1);
    Graph[b - 1].push_back(a - 1);
  }
  dfs(0);
  while (!Queue.empty()) {
    int k = Queue.front();
    for (int& i : Graph[k]) {
      if (!IsVisited2[i]) {
        IsVisited2[i] = true;
        Queue.push(i);
        Distances[i] = Distances[k] + 1;
      }
    }
    Queue.pop();
  }
  for (int& i : Distances) {
    cout << i << " ";
  }
  return 0;
}
