#include <bits/stdc++.h>
using namespace std;
vector<int> G[3010];
stack<int> S;
queue<int> Q;
int N, i;
int viz[3010], parent[3010], d[3010];
bool gata = false;
void DFS(int nod) {
  viz[nod] = 1;
  for (int i = 0; i < G[nod].size(); ++i)
    if (!viz[G[nod][i]]) {
      parent[G[nod][i]] = nod;
      DFS(G[nod][i]);
    }
}
void GetCicle(int nod) {
  viz[nod] = 1;
  for (int i = 0; i < G[nod].size() && !gata; ++i) {
    int vecin = G[nod][i];
    if (!viz[G[nod][i]]) {
      S.push(vecin);
      GetCicle(vecin);
      if (!gata) S.pop();
    } else if (viz[G[nod][i]] && parent[nod] != vecin) {
      S.push(vecin);
      gata = true;
    }
  }
}
void BFS() {
  int x;
  while (!Q.empty()) {
    x = Q.front();
    Q.pop();
    for (i = 0; i < G[x].size(); ++i)
      if (!viz[G[x][i]]) {
        viz[G[x][i]] = 1;
        d[G[x][i]] = d[x] + 1;
        Q.push(G[x][i]);
      }
  }
}
int main() {
  int a, b;
  cin >> N;
  for (i = 1; i <= N; ++i) {
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  DFS(1);
  S.push(1);
  for (i = 1; i <= N; ++i) viz[i] = 0;
  GetCicle(1);
  for (i = 1; i <= N; ++i) viz[i] = 0;
  int vf = S.top();
  viz[S.top()] = 1;
  S.pop();
  Q.push(vf);
  while (S.top() != vf) {
    Q.push(S.top());
    viz[S.top()] = 1;
    S.pop();
  }
  BFS();
  for (i = 1; i <= N; ++i) cout << d[i] << ' ';
  cout << '\n';
  return 0;
}
