#include <bits/stdc++.h>
using namespace std;
void iplf(long int &num) {
  num = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    num = 10 * num + c - '0';
    c = getchar();
  }
  return;
}
long int n;
vector<long int> adj[3003];
vector<long int> cyc;
long int visited[3003];
long int ans[3003];
bool dfs(long int node, long int par) {
  if (adj[node].size() == 0) return false;
  for (long int i = 0; i < adj[node].size(); i++) {
    long int nxt = adj[node][i];
    if (nxt == par) continue;
    if (visited[nxt]) {
      cyc.push_back(nxt);
      cyc.push_back(node);
      return true;
    }
    visited[nxt] = true;
    bool key = dfs(nxt, node);
    if (key) {
      if (node != cyc[0]) {
        cyc.push_back(node);
        return true;
      }
      return false;
    }
  }
  return false;
}
void _dfs(long int start) {
  stack<pair<long int, long int> > stk;
  stack<long int> par;
  stk.push(make_pair(cyc[start], 0));
  par.push(0);
  while (!stk.empty()) {
    long int node = (stk.top()).first;
    long int lvl = (stk.top()).second;
    long int parr = par.top();
    par.pop();
    stk.pop();
    for (long int i = 0; i < adj[node].size(); i++) {
      long int nxt = adj[node][i];
      if (nxt == parr) continue;
      if (node == cyc[start] &&
          (nxt == cyc[start - 1] || nxt == cyc[start + 1]))
        continue;
      stk.push(make_pair(nxt, lvl + 1));
      par.push(node);
      ans[nxt] = lvl + 1;
    }
  }
  return;
}
void solve() {
  scanf("%ld", &n);
  for (long int i = 1; i <= n; i++) {
    long int x, y;
    scanf("%ld", &x);
    scanf("%ld", &y);
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  visited[1] = true;
  dfs(1, 0);
  cyc.push_back(cyc[0]);
  cyc.push_back(cyc[1]);
  for (long int i = 1; i < cyc.size() - 1; i++) _dfs(i);
  for (long int i = 1; i <= n; i++) printf("%ld", ans[i]), printf(" ");
  return;
}
int main() {
  solve();
  return 0;
}
