#include <bits/stdc++.h>
using namespace std;
map<int, int> mp;
vector<int> v5;
class Graph {
 public:
  int V;
  int distance[3005];
  map<int, vector<int>> adj;
  Graph(int x) { V = x; }
  void addedge(int u, int v) {
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  int st_cycle;
  int ekbar = 0;
  void dfs_cycle(int node, map<int, bool>& visited, map<int, int>& parent) {
    visited[node] = true;
    for (auto nbr : adj[node]) {
      if (visited[nbr] == true && parent[node] != nbr) {
        st_cycle = node;
        return;
      } else {
        if (visited[nbr] == false) {
          parent[nbr] = node;
          dfs_cycle(nbr, visited, parent);
        }
      }
    }
    return;
  }
  void dfs_holder(int node, map<int, bool>& visited2, vector<int> vect,
                  int st_cycle, int time) {
    visited2[node] = true;
    vect.push_back(node);
    if (node == st_cycle && time == 1) {
      if (vect.size() > v5.size()) v5 = vect;
      return;
    }
    int pst = 0;
    for (auto nbr : adj[node]) {
      if (nbr == st_cycle) pst = 1;
      if (visited2[nbr] == false && nbr != st_cycle) {
        dfs_holder(nbr, visited2, vect, st_cycle, 0);
      }
    }
    if (pst == 1) dfs_holder(st_cycle, visited2, vect, st_cycle, 1);
    vect.pop_back();
    return;
  }
  void dfs_dist(int node, map<int, bool>& visited3, int dist) {
    visited3[node] = true;
    if (mp[node] == 1) dist = 0;
    distance[node] = dist;
    for (auto nbr : adj[node]) {
      if (visited3[nbr] == false) {
        dfs_dist(nbr, visited3, dist + 1);
      }
    }
    return;
  }
  void dfs() {
    map<int, bool> visited;
    map<int, int> parent;
    parent[1] = 1;
    dfs_cycle(1, visited, parent);
    map<int, bool> visited2;
    vector<int> vect;
    dfs_holder(st_cycle, visited2, vect, st_cycle, 0);
    for (auto gh : v5) {
      mp[gh] = 1;
    }
    map<int, bool> visited3;
    dfs_dist(st_cycle, visited3, 0);
    for (int sk = 1; sk <= V; sk++) {
      cout << distance[sk] << " ";
    }
    cout << endl;
  }
};
int main() {
  int n, i, j, x, y, p, m, z, t, src, dest, k;
  cin >> n;
  Graph g(n);
  m = n;
  for (i = 1; i <= m; i++) {
    cin >> x >> y;
    g.addedge(x, y);
  }
  g.dfs();
  return 0;
}
