#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > a;
vector<int> parent;
vector<int> dist, ans;
int t;
void dfs(int u, int par) {
  parent[u] = par;
  int i;
  for (i = 0; i < a[u].size(); i++) {
    if (parent[a[u][i]] == 0) {
      dfs(a[u][i], u);
      if (dist[a[u][i]] != 0) dist[a[u][i]] = dist[u] + 1;
    } else if (a[u][i] != par && dist[u] != 0) {
      t = u;
      while (t != a[u][i]) {
        ans.push_back(t);
        dist[t] = 0;
        t = parent[t];
      }
      dist[a[u][i]] = 0;
      ans.push_back(a[u][i]);
    }
  }
}
void dfs2(int u, int par) {
  int i;
  for (i = 0; i < a[u].size(); i++) {
    if (a[u][i] != par && dist[a[u][i]] != 0) {
      dist[a[u][i]] = 1 + dist[u];
      dfs2(a[u][i], u);
    }
  }
}
int main() {
  int n, m, i, x, y;
  scanf("%d", &n);
  a.resize(n + 1);
  dist.resize(n + 1);
  parent.resize(n + 1);
  for (i = 0; i < n; i++) {
    scanf("%d %d", &x, &y);
    a[x].push_back(y);
    a[y].push_back(x);
  }
  for (i = 1; i <= n; i++) dist[i] = 1;
  int p;
  if (a[1].size() > 1)
    p = a[1][1];
  else
    p = a[1][0];
  dfs(1, p);
  for (i = 0; i < ans.size(); i++) {
    dfs2(ans[i], 0);
  }
  for (i = 1; i <= n; i++) printf("%d ", dist[i]);
  return 0;
}
