#include <bits/stdc++.h>
using namespace std;
int n, par[100009], b, k, p, dis[100009];
vector<int> adj[100009], cycle;
bool mark[100009];
void dfs(int v) {
  mark[v] = true;
  for (int i = 0; i < adj[v].size(); i++) {
    if (!mark[adj[v][i]]) {
      par[adj[v][i]] = v;
      dfs(adj[v][i]);
    } else if (adj[v][i] != par[v]) {
      b = v;
      p = adj[v][i];
    }
  }
}
void bfs(int u) {
  for (int i = 0; i < adj[u].size(); i++) {
    if (!mark[adj[u][i]]) {
      dis[adj[u][i]] = dis[u] + 1;
      mark[adj[u][i]] = true;
      bfs(adj[u][i]);
    }
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    adj[x - 1].push_back(y - 1);
    adj[y - 1].push_back(x - 1);
  }
  dfs(0);
  cycle.push_back(b);
  while (p != b) {
    cycle.push_back(p);
    p = par[p];
  }
  fill(mark, mark + n, 0);
  for (int i = 0; i < cycle.size(); i++) {
    mark[cycle[i]] = true;
  }
  for (int i = 0; i < cycle.size(); i++) {
    bfs(cycle[i]);
  }
  for (int i = 0; i < n; i++) {
    cout << dis[i] << " ";
  }
  return 0;
}
