#include <bits/stdc++.h>
using namespace std;
void dfs(vector<vector<int> > &adj, vector<int> &parent, int n, int &start,
         bool &b) {
  for (int i = 0; i < adj[n].size(); i++) {
    if (parent[adj[n][i]] == -1) {
      parent[adj[n][i]] = n;
      dfs(adj, parent, adj[n][i], start, b);
      if (b == true) break;
    } else if (b == false) {
      if (parent[n] != adj[n][i]) {
        parent[adj[n][i]] = n;
        start = n;
        b = true;
      }
    }
  }
}
void depth(vector<vector<int> > &adj, int n, vector<int> &part_of_cycle,
           int level, vector<int> &distance) {
  for (int i = 0; i < adj[n].size(); i++) {
    if (distance[adj[n][i]] == -1) {
      if (part_of_cycle[adj[n][i]] == 0) {
        distance[adj[n][i]] = level;
        depth(adj, adj[n][i], part_of_cycle, level + 1, distance);
      } else {
        distance[adj[n][i]] = 0;
        depth(adj, adj[n][i], part_of_cycle, 1, distance);
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<vector<int> > adj(n + 1);
  for (int i = 1; i <= n; i++) {
    int t1, t2;
    cin >> t1 >> t2;
    adj[t1].push_back(t2);
    adj[t2].push_back(t1);
  }
  vector<int> parent(n + 1, -1);
  parent[1] = 0;
  int start = -1;
  bool b = false;
  dfs(adj, parent, 1, start, b);
  vector<int> cycle;
  int temp = parent[start];
  vector<int> part_of_cycle(n + 1, 0);
  part_of_cycle[start] = 1;
  while (temp != start) {
    part_of_cycle[temp] = 1;
    temp = parent[temp];
  }
  vector<int> distance(n + 1, -1);
  distance[start] = 0;
  depth(adj, start, part_of_cycle, 1, distance);
  for (int i = 1; i <= n; i++) {
    cout << distance[i] << " ";
  }
  return 0;
}
