#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > graph;
int vis[3000];
int par[3000];
int k, b;
int level[3000];
void dfs1(int);
void bfs2(int);
vector<int> cyc;
int main() {
  int n;
  cin >> n;
  graph.clear();
  graph.resize(n);
  memset(par, 0, sizeof par);
  int x, y;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    x--;
    y--;
    graph[x].push_back(y);
    graph[y].push_back(x);
  }
  memset(level, 0, sizeof level);
  memset(vis, 0, sizeof vis);
  dfs1(0);
  swap(b, k);
  cyc.push_back(k);
  while (b != k) {
    cyc.push_back(par[k]);
    k = par[k];
  }
  memset(vis, 0, sizeof vis);
  for (int i = 0; i < cyc.size(); i++) vis[cyc[i]] = 1;
  for (int i = 0; i < cyc.size(); i++) bfs2(cyc[i]);
  for (int i = 0; i < n; i++) cout << level[i] << " ";
}
void dfs1(int s) {
  vis[s] = 1;
  for (int i = 0; i < graph[s].size(); i++) {
    int v = graph[s][i];
    if (!vis[v]) {
      par[v] = s;
      dfs1(v);
    } else if (par[s] != v) {
      k = s;
      b = v;
    }
  }
}
void bfs2(int sommet) {
  queue<int> q;
  q.push(sommet);
  vis[sommet] = 1;
  level[sommet] = 0;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = 0; i < graph[u].size(); i++) {
      int v = graph[u][i];
      if (!vis[v]) {
        q.push(v);
        level[v] = 1 + level[u];
        vis[v] = 1;
      }
    }
  }
}
