#include <bits/stdc++.h>
using namespace std;
long long n, cv;
long long level[3501];
long long vis[3501] = {};
vector<long long> graph[3501];
vector<long long> cycles[3501];
vector<long long> z;
void dfs_cycle(long long u, long long p, long long color[], long long mark[],
               long long par[], long long& cyclenumber) {
  if (color[u] == 2) {
    return;
  }
  if (color[u] == 1) {
    cyclenumber++;
    long long cur = p;
    mark[cur] = cyclenumber;
    while (cur != u) {
      cur = par[cur];
      mark[cur] = cyclenumber;
    }
    return;
  }
  par[u] = p;
  color[u] = 1;
  for (long long v : graph[u]) {
    if (v == par[u]) {
      continue;
    }
    dfs_cycle(v, u, color, mark, par, cyclenumber);
  }
  color[u] = 2;
}
void printCycles(long long edges, long long mark[], long long& cyclenumber) {
  for (long long i = 1; i <= edges; i++) {
    if (mark[i] != 0) cycles[mark[i]].push_back(i);
  }
  for (long long i = 1; i <= cyclenumber; i++) {
    for (long long x : cycles[i]) z.push_back(x);
  }
}
void bfs(long long s) {
  queue<long long> q;
  q.push(s);
  level[s] = 0;
  vis[s] = 1;
  while (!q.empty()) {
    long long p = q.front();
    q.pop();
    for (long long i = 0; i < graph[p].size(); i++) {
      if (vis[graph[p][i]] == 0) {
        level[graph[p][i]] = min(level[graph[p][i]], level[p] + 1);
        q.push(graph[p][i]);
        vis[graph[p][i]] = 1;
      }
    }
  }
}
void quickly_quickly_kro() {
  cin >> n;
  for (long long i = 1; i < n + 1; i++) {
    long long a, b;
    cin >> a >> b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  long long color[3501];
  long long par[3501];
  long long mark[3501];
  long long cyclenumber = 0;
  long long edges = n;
  dfs_cycle(1, 0, color, mark, par, cyclenumber);
  printCycles(edges, mark, cyclenumber);
  for (long long i = 1; i < n + 1; i++) level[i] = (long long)2e18;
  for (auto k : z) {
    for (long long i = 1; i < n + 1; i++) {
      vis[i] = 0;
    }
    bfs(k);
  }
  for (long long i = 1; i < n + 1; i++) {
    cout << level[i] << " ";
  }
}
signed main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  t = 1;
  while (t--) {
    quickly_quickly_kro();
    cout << "\n";
  }
  return 0;
}
