#include <bits/stdc++.h>
using namespace std;
int n;
int x, y;
vector<int> g[3005];
int d[3005];
int cnt;
int inEdges[3005];
vector<int> order;
bool mark[3005];
void findCycle() {
  for (int u = 1; u <= n; u++)
    for (int v = 0; v < g[u].size(); v++) inEdges[g[u][v]]++;
  for (int u = 1; u <= n; u++)
    if (inEdges[u] == 1) order.push_back(u);
  int v = 0;
  while (v < order.size()) {
    for (int u = 0; u < g[order[v]].size(); u++) {
      inEdges[g[order[v]][u]]--;
      if (inEdges[g[order[v]][u]] == 1) order.push_back(g[order[v]][u]);
    }
    v++;
  }
  for (int u = 1; u <= n; u++)
    if (inEdges[u] > 1) {
      d[u] = 0;
      mark[u] = true;
      cnt++;
    }
}
int minIndex() {
  int u = -1;
  for (int v = 1; v <= n; v++)
    if (!mark[v] && d[v] > -1)
      if (u == -1 || d[u] > d[v]) u = v;
  return u;
}
void dijkstra() {
  for (int u = 1; u <= n; u++)
    if (d[u] == 0)
      for (int v = 0; v < g[u].size(); v++) {
        if (d[g[u][v]] == -1) d[g[u][v]] = 1;
      }
  for (int i = 1; i <= n - cnt; i++) {
    int u = minIndex();
    mark[u] = true;
    for (int v = 0; v < g[u].size(); v++)
      if (!mark[g[u][v]])
        if (d[g[u][v]] == -1 || d[g[u][v]] < d[u] + 1) d[g[u][v]] = d[u] + 1;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &x, &y);
    g[x].push_back(y);
    g[y].push_back(x);
  }
  for (int i = 1; i <= n; i++) d[i] = -1;
  findCycle();
  dijkstra();
  for (int i = 1; i <= n; i++) printf("%d ", d[i]);
  printf("\n");
  return 0;
}
