#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
vector<vector<int> > v;
bool inCycle[3001];
int vis[3001], par[3001], dist[3001];
void dfsCycle(int p, int n) {
  vis[n] = 1;
  for (int i = (0); i < ((int)v[n].size()); i++) {
    if (vis[v[n][i]] == 1 && p != v[n][i]) {
      int pr = p, cur = v[n][i];
      inCycle[n] = 1;
      dist[n] = 0;
      while (pr != par[v[n][i]]) {
        cur = pr;
        inCycle[cur] = 1;
        dist[cur] = 0;
        pr = par[pr];
      }
    } else if (!vis[v[n][i]])
      par[v[n][i]] = n, dfsCycle(n, v[n][i]);
  }
  vis[n] = 2;
}
void dfs(int n, int c) {
  vis[n] = 1;
  for (int i = (0); i < ((int)v[n].size()); i++) {
    if (!vis[v[n][i]] && !inCycle[v[n][i]]) {
      dist[v[n][i]] = c + 1;
      dfs(v[n][i], c + 1);
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  int n, x, y;
  cin >> n;
  v.resize(n);
  for (int i = (0); i < (n); i++) {
    cin >> x >> y;
    --x, --y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  memset(inCycle, 0, sizeof(inCycle));
  memset(vis, 0, sizeof(vis));
  memset(par, -1, sizeof(par));
  dfsCycle(-1, 0);
  memset(vis, 0, sizeof(vis));
  for (int i = (0); i < (n); i++)
    if (inCycle[i]) dfs(i, 0);
  for (int i = (0); i < (n); i++) cout << dist[i] << " ";
  return 0;
}
