#include <bits/stdc++.h>
using namespace std;
const int _maxio = 1000000;
char _buf[_maxio], *_s = _buf + _maxio;
inline char _getc(void) {
  if (_s >= _buf + _maxio) {
    fread(_buf, sizeof(char), _maxio, stdin);
    _s = _buf;
  }
  return *(_s++);
}
inline int ni(void) {
  char _t = _getc();
  int _n = 1, _res = 0;
  while (_t != '-' && !isdigit(_t)) _t = _getc();
  if (_t == '-') {
    _n = -1;
    _t = _getc();
  }
  while (isdigit(_t)) {
    _res = 10 * _res + (_t & 15);
    _t = _getc();
  }
  return _res * _n;
}
const int maxn = 3050;
vector<int> buf[maxn];
bool vis[maxn] = {};
int dis[maxn] = {};
int tag = 0;
int pt = -1;
vector<int> ring;
void dfs(int t, int from) {
  if (vis[t]) {
    pt = t;
    tag = 1;
    return;
  }
  vis[t] = true;
  for (vector<int>::iterator it = buf[t].begin(); it != buf[t].end(); it++)
    if (*it != from) {
      dfs(*it, t);
      if (tag == 1) {
        ring.push_back(t);
        if (pt == t) tag = 2;
        return;
      }
      if (tag == 2) return;
    }
}
int main(void) {
  int n = ni();
  for (int i = 0; i < (n); ++i) {
    int a = ni() - 1, b = ni() - 1;
    buf[a].push_back(b);
    buf[b].push_back(a);
  }
  dfs(1, -1);
  memset(vis, 0, sizeof(vis));
  queue<int> q;
  for (vector<int>::iterator it = ring.begin(); it != ring.end(); it++) {
    q.push(*it);
    vis[*it] = true;
  }
  while (!q.empty()) {
    int t = q.front();
    q.pop();
    for (vector<int>::iterator it = buf[t].begin(); it != buf[t].end(); it++)
      if (!vis[*it]) {
        dis[*it] = dis[t] + 1;
        vis[*it] = true;
        q.push(*it);
      }
  }
  for (int i = 0; i < (n); ++i) cout << dis[i] << ' ';
  cout << endl;
}
