#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3000;
bool foundCycle = false;
bool visited[MAXN + 1];
int distances[MAXN + 1];
vector<int> adj[MAXN + 1];
int cycleStart, parents[MAXN + 1];
void findCycle(int node, int prevNode) {
  if (parents[node] != 0) {
    cycleStart = prevNode;
    int currStation = prevNode;
    distances[node] = 0;
    while (currStation != node) {
      distances[currStation] = 0;
      currStation = parents[currStation];
    }
    foundCycle = true;
    return;
  } else {
    parents[node] = prevNode;
    for (int v : adj[node]) {
      if (!foundCycle && v != prevNode) findCycle(v, node);
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int a, b;
    cin >> a >> b;
    distances[i] = -1;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  findCycle(1, -1);
  stack<int> s;
  s.push(cycleStart);
  visited[cycleStart] = true;
  while (!s.empty()) {
    int u = s.top();
    s.pop();
    int currDistance = distances[u];
    for (int v : adj[u]) {
      if (!visited[v]) {
        visited[v] = true;
        s.push(v);
        if (distances[v] == -1) {
          distances[v] = currDistance + 1;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) cout << distances[i] << " ";
  cout << "\n";
}
