#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> graph[3001];
int vis[3001], cyc[3001], res[3001];
void dfs(int node, int prev) {
  vis[node]++;
  if (vis[node] == 3) {
    cyc[node] = 1;
  }
  for (int i = 0; i < graph[node].size(); i++) {
    if (vis[graph[node][i]] < 3 && graph[node][i] != prev)
      dfs(graph[node][i], node);
  }
  vis[node]--;
}
void dfs1(int node, int prev, int way) {
  res[node] = way;
  for (int i = 0; i < graph[node].size(); i++)
    if (!cyc[graph[node][i]] && graph[node][i] != prev)
      dfs1(graph[node][i], node, way + 1);
}
int main() {
  memset(vis, 0, sizeof vis);
  memset(cyc, 0, sizeof cyc);
  memset(res, 0, sizeof res);
  cin >> n;
  for (int i = 0; i < n; i++) {
    int from, to;
    cin >> from >> to;
    graph[from].push_back(to);
    graph[to].push_back(from);
  }
  dfs(1, -1);
  for (int i = 1; i <= n; i++)
    if (cyc[i]) dfs1(i, -1, 0);
  for (int i = 1; i <= n; i++) cout << res[i] << " ";
}
