#include <bits/stdc++.h>
using namespace std;
void loadData(void);
void proc(void);
void printRes(void);
void findLoop(void);
bool dfs(int index);
void getRes(void);
int getDepth(int index);
int n;
vector<int> subway[3000];
int res[3000];
bool visit[3000];
vector<int> cycleVector;
vector<int> loop;
int loopTag;
bool lyb_debug = false;
int main(int argc, char** argv) {
  loadData();
  proc();
  printRes();
  return 0;
}
int getDepth(int index) {
  visit[index] = true;
  if (subway[index].size() == 1 && visit[subway[index][0]]) return 1000000000;
  int res = 1000000000;
  for (int i = 0; i < subway[index].size(); i++) {
    if (binary_search(loop.begin(), loop.end(), subway[index][i]))
      return 1;
    else if (!visit[subway[index][i]])
      res = min(res, 1 + getDepth(subway[index][i]));
  }
  return res;
}
void getRes(void) {
  sort(loop.begin(), loop.end());
  for (int i = 0; i < n; i++) {
    if (binary_search(loop.begin(), loop.end(), i))
      res[i] = 0;
    else {
      memset(visit, false, sizeof(visit));
      res[i] = getDepth(i);
    }
  }
  return;
}
bool dfs(int index) {
  visit[index] = true;
  cycleVector.push_back(index);
  vector<int>::iterator iter;
  for (int i = 0; i < subway[index].size(); i++) {
    if (visit[subway[index][i]] &&
        (iter = find(cycleVector.begin(), cycleVector.end(),
                     subway[index][i])) != cycleVector.end() &&
        cycleVector.end() - iter > 2) {
      loopTag = subway[index][i];
      return true;
    } else if (!visit[subway[index][i]])
      if (dfs(subway[index][i])) return true;
  }
  cycleVector.pop_back();
  return false;
}
void findLoop(void) {
  memset(visit, false, sizeof(visit));
  loop.clear();
  cycleVector.clear();
  for (int i = 0; i < n; i++) {
    if (!visit[i])
      if (dfs(i)) break;
  }
  int i;
  for (i = 0;; i++)
    if (cycleVector[i] == loopTag) break;
  for (; i < cycleVector.size(); i++) loop.push_back(cycleVector[i]);
  if (lyb_debug) {
    printf("loop info:\n");
    for (int i = 0; i < loop.size(); i++) printf("%d ", loop[i]);
    printf("\n");
    printf("loopTag:%d\n", loopTag);
    printf("\n");
  }
  return;
}
void proc(void) {
  memset(res, 0, sizeof(res));
  findLoop();
  getRes();
  return;
}
void loadData(void) {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) subway[i].clear();
  int x, y;
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &x, &y);
    x--;
    y--;
    subway[x].push_back(y);
    subway[y].push_back(x);
  }
  return;
}
void printRes(void) {
  for (int i = 0; i < n; i++) printf("%d%c", res[i], i == n - 1 ? '\n' : ' ');
  return;
}
