#include <bits/stdc++.h>
using namespace std;
vector<int> adj[30005];
int par[3005], col[3005], cycle_start = -1, cycle_end = -1, d[3005];
queue<int> q;
bool dfs(int u) {
  int i;
  col[u] = 1;
  for (i = 0; i < adj[u].size(); i++) {
    if (adj[u][i] == par[u]) continue;
    if (col[adj[u][i]] == 0) {
      par[adj[u][i]] = u;
      if (dfs(adj[u][i])) return true;
    } else if (col[adj[u][i]] == 1) {
      cycle_start = adj[u][i];
      cycle_end = u;
      return true;
    }
  }
  col[u] = 2;
  return false;
}
void bfs(vector<int> cycle) {
  int i, u;
  memset(d, 0x7F, sizeof(d));
  memset(col, 0, sizeof(col));
  for (i = 0; i < cycle.size(); i++) {
    d[cycle[i]] = 0;
    q.push(cycle[i]);
  }
  while (!q.empty()) {
    u = q.front();
    q.pop();
    col[u] = 1;
    for (i = 0; i < adj[u].size(); i++) {
      if (col[adj[u][i]] == 0 && d[adj[u][i]] > d[u] + 1) {
        d[adj[u][i]] = d[u] + 1;
        q.push(adj[u][i]);
      }
    }
  }
}
int main() {
  int n, i, j, cnt = 0, x, y;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  memset(par, -1, sizeof(par));
  memset(col, 0, sizeof(col));
  par[1] = 1;
  if (dfs(1)) {
    vector<int> cycle;
    for (x = cycle_end; x != cycle_start; x = par[x]) cycle.push_back(x);
    cycle.push_back(cycle_start);
    bfs(cycle);
    for (i = 1; i <= n; i++) cout << d[i] << " ";
    cout << endl;
  }
  return 0;
}
