#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:64000000")
template <class T>
inline T sqr(T a) {
  return a * a;
}
vector<vector<int> > g;
vector<int> p;
int st = -1, en = -1;
vector<int> d;
void dfs(int x, int par) {
  p[x] = par;
  for (int i = 0; i < (int)g[x].size(); ++i) {
    if (st != -1) return;
    int to = g[x][i];
    if (to == par) continue;
    if (p[to] == -1) {
      dfs(to, x);
      continue;
    }
    st = to;
    en = x;
    return;
  }
}
void dfs1(int x, int c) {
  d[x] = c;
  for (int i = 0; i < (int)g[x].size(); ++i) {
    if (d[g[x][i]] != -1) continue;
    dfs1(g[x][i], c + 1);
  }
}
int main() {
  int n;
  scanf("%d", &n);
  g.resize(n);
  p.assign(n, -1);
  for (int i = 0; i < n; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    --u;
    --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(0, -2);
  d.assign(n, -1);
  vector<int> start;
  int cur = en;
  while (cur != st) {
    start.push_back(cur);
    d[cur] = 0;
    cur = p[cur];
  }
  start.push_back(cur);
  d[cur] = 0;
  for (int i = 0; i < (int)start.size(); ++i) dfs1(start[i], 0);
  for (int i = 0; i < n; ++i) printf("%d ", d[i]);
  return 0;
}
