#include <bits/stdc++.h>
using namespace std;
string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
const long double pie = 3.1415926535897932384626;
const long long mod = 1e9 + 7;
int n;
const int N = 3e3 + 10;
vector<int> g[N];
void read() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
}
stack<int> temp;
bool in_stack[N], vis[N];
int start = -1;
bool ok = false;
void dfs(int node, int parent = -1) {
  vis[node] = 1;
  temp.push(node);
  in_stack[node] = 1;
  for (auto &i : g[node]) {
    if (i == parent) continue;
    ;
    if (in_stack[i]) {
      start = i;
      ok = true;
      return;
    }
    if (vis[i]) continue;
    ;
    dfs(i, node);
    if (ok) return;
  }
  if (ok) return;
  in_stack[node] = false;
  temp.pop();
}
int ans[N];
void multi_source_bfs() {
  for (int i = 0; i < n; i++) vis[i] = false;
  queue<int> q;
  for (;;) {
    auto node = temp.top();
    temp.pop();
    q.push(node);
    vis[node] = 1;
    if (node == start) break;
  }
  while (q.empty() == false) {
    auto node = q.front();
    q.pop();
    for (auto &i : g[node]) {
      if (vis[i]) continue;
      ;
      vis[i] = 1;
      q.push(i);
      ans[i] = ans[node] + 1;
    }
  }
}
void solve(int test_case) {
  read();
  dfs(0);
  multi_source_bfs();
  for (int i = 0; i < n; i++) cout << ans[i] << " ";
  cout << "\n";
  ;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  for (int i = 1; i <= t; i++) solve(i);
  return 0;
}
