#include <bits/stdc++.h>
using namespace std;
void scanint(int &x) {
  register int c = getchar();
  x = 0;
  int m = 0;
  if (c == '-') m = 1;
  for (; (c < 48 || c > 57); c = getchar())
    ;
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  if (m == 1) x *= -1;
}
int V;
std::vector<std::vector<int> > g;
std::vector<int> path;
int prev;
int dist[3301];
void printstack() {
  for (int i = 0; i < path.size(); ++i) {
    printf("%d\n", path[i]);
  }
}
void getpath() {
  int status[3001] = {0};
  std::vector<int> prev;
  stack<int> s;
  status[1] = 1;
  s.push(1);
  while (!s.empty()) {
    int top = s.top();
    if (g[top].size() == 0) {
      status[top] = 2;
      s.pop();
    } else {
      int xcount = 0;
      for (int i = 0; i < g[top].size(); ++i) {
        int ngb = g[top][i];
        if (status[ngb] == 0) {
          xcount++;
          prev.push_back(s.top());
          s.push(ngb);
          top = s.top();
          status[ngb] = 1;
          continue;
        } else if (status[ngb] == 1 && ngb != prev.back()) {
          xcount++;
          while (1) {
            int x = s.top();
            path.push_back(x);
            s.pop();
            if (x == ngb) {
              prev.clear();
              return;
            }
          }
          continue;
        }
      }
      if (xcount == 0) {
        status[top] = 2;
        s.pop();
        prev.pop_back();
      }
    }
  }
}
void print() {
  for (int i = 1; i <= V; ++i) {
    printf("%d--", i);
    for (int j = 0; j < g[i].size(); ++j) {
      printf("%d,", g[i][j]);
    }
    printf("\n");
  }
}
void getdist() {
  queue<int> q;
  int status[3010] = {0};
  for (int i = 0; i < path.size(); ++i) {
    dist[path[i]] = 0;
    status[path[i]] = 2;
    q.push(path[i]);
  }
  while (!q.empty()) {
    int top = q.front();
    q.pop();
    for (int i = 0; i < g[top].size(); ++i) {
      if (status[g[top][i]] != 2) {
        dist[g[top][i]] = dist[top] + 1;
        q.push(g[top][i]);
        status[g[top][i]] = 2;
      }
    }
  }
  for (int i = 1; i <= V; ++i) {
    printf("%d\n", dist[i]);
  }
}
int main() {
  scanint(V);
  g.resize(V + 1);
  int x, y;
  for (int i = 0; i < V; ++i) {
    scanint(x);
    scanint(y);
    g[x].push_back(y);
    g[y].push_back(x);
  }
  getpath();
  getdist();
  return 0;
}
