#include <bits/stdc++.h>
using namespace std;
void read() { freopen("in", "r", stdin); }
vector<int> v[5000];
queue<int> q;
int visited[5000];
bool cycle[5000];
int dist[5000];
vector<int> target;
int last, from;
int ans = 0;
int parent[5000];
int n;
int len = 0;
void build(int node) {
  q.push(node);
  dist[node] = 0;
  if (node == from) return;
  build(parent[node]);
}
void dfs(int node, int p = -1) {
  if (ans) return;
  parent[node] = p;
  visited[node] = 1;
  for (int i = 0; i < v[node].size(); i++) {
    if (v[node][i] == p || visited[v[node][i]] == 2) continue;
    if (visited[v[node][i]] == 1) {
      from = node;
      ans = 1;
      last = v[node][i];
      return;
    }
    dfs(v[node][i], node);
  }
  visited[node] = 2;
}
int main() {
  cin >> n;
  memset(dist, -1, sizeof dist);
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  int len = 0;
  dfs(1);
  build(last);
  while (!q.empty()) {
    len++;
    int sz = q.size();
    while (sz--) {
      int cur = q.front();
      q.pop();
      for (int i = 0; i < v[cur].size(); i++) {
        int child = v[cur][i];
        if (dist[child] != -1) continue;
        dist[child] = len;
        q.push(child);
      }
    }
  }
  for (int i = 1; i <= n; i++) cout << dist[i] << " ";
  cout << endl;
  return 0;
}
