#include <bits/stdc++.h>
using namespace std;
const int oo = 999999999;
const double PI = 3.1415931;
const int maxN = 3000 + 300;
int n;
bool buf = false;
bool dor[maxN];
bool mark[maxN];
int par[maxN];
vector<int> v[maxN];
int d1, d2;
int dis[maxN];
bool mark2[maxN];
void fandis(int x, int h) {
  dis[x] = h;
  mark2[x] = true;
  for (int i = 0; i < v[x].size(); i++) {
    int tmp = v[x][i];
    if (!dor[tmp] && !mark2[tmp]) {
      fandis(tmp, h + 1);
    }
  }
  return;
}
void dfs(int x) {
  if (buf) return;
  mark[x] = true;
  for (int i = 0; i < v[x].size(); i++) {
    int tmp = v[x][i];
    if (mark[tmp] == false) {
      par[tmp] = x;
      dfs(tmp);
    } else if (mark[tmp] == true && tmp != par[x]) {
      d2 = tmp;
      d1 = x;
      buf = true;
    }
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int a, b;
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  par[1] = -1;
  dfs(1);
  vector<int> id;
  while (d2 != d1) {
    id.push_back(d2);
    dor[d2] = true;
    d2 = par[d2];
  }
  id.push_back(d1);
  dor[d1] = true;
  for (int i = 0; i < id.size(); i++) fandis(id[i], 0);
  for (int i = 1; i <= n; i++) cout << dis[i] << " ";
  cout << endl;
  int _;
  cin >> _;
  return 0;
}
