#include <bits/stdc++.h>
using namespace std;
void c_p_c() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
bool cmp(vector<int> v1, vector<int> v2) { return v1[0] > v2[0]; }
vector<int> adj[30001];
int vis[3001];
int par[3001];
long long a = 0, b = 0;
int arr[3001];
bool dfs(int node, int parent) {
  par[node] = parent;
  vis[node] = 1;
  for (int child : adj[node]) {
    if (vis[child] == 0) {
      if (dfs(child, node) == true) return true;
    } else if (vis[child] == 1 && child != parent) {
      a = child;
      b = node;
      return true;
    }
  }
  return false;
}
void dfs1(int node) {
  vis[node] = 1;
  for (int child : adj[node]) {
    if (vis[child] == 0) {
      if (arr[child - 1] == -1) {
        arr[child - 1] = arr[node - 1] + 1;
      }
      dfs1(child);
    }
  }
}
int main() {
  c_p_c();
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    arr[i] = -1;
  }
  for (long long i = 0; i < n; i++) {
    long long u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      vis[j] = 0;
      par[j] = 0;
    }
    if (dfs(i, -1) == true) break;
  }
  int i = b;
  while (i != a) {
    arr[i - 1] = 0;
    i = par[i];
  }
  arr[a - 1] = 0;
  for (int j = 1; j <= n; j++) {
    vis[j] = 0;
    par[j] = 0;
  }
  dfs1(a);
  for (long long i = 0; i < n; i++) {
    cout << arr[i] << " ";
  }
  return 0;
}
