#include <bits/stdc++.h>
template <class T>
inline T gcd(T a, T b) {
  while (b) b ^= a ^= b ^= a %= b;
  return a;
}
template <class T>
inline T pow(T a, T b, T c) {
  T re = 1;
  while (b) {
    if (b & 1) re = (re * a) % c;
    a = (a * a) % c;
    b >>= 1;
  }
  return re;
}
template <class T>
inline void read(T& x) {
  bool fu = 0;
  char c;
  for (c = getchar(); c <= 32; c = getchar())
    ;
  if (c == '-') fu = 1, c = getchar();
  for (x = 0; c > 32; c = getchar()) x = x * 10 + c - '0';
  if (fu) x = -x;
};
template <class T>
inline void read(T& x, T& y) {
  read(x);
  read(y);
}
template <class T>
inline void read(T& x, T& y, T& z) {
  read(x);
  read(y);
  read(z);
}
using namespace std;
const int MAX = 3005;
bool visited[MAX], flag;
vector<int> adj[MAX];
int parent[MAX], dist[MAX], z;
void dfs(int from) {
  visited[from] = true;
  for (int i = 0; i < (int)adj[from].size(); i += 1) {
    int to = adj[from][i];
    if (visited[to] == false) {
      parent[to] = from;
      dfs(to);
    } else if (parent[from] != to and flag) {
      z = to;
      parent[to] = from;
      flag = false;
    }
  }
}
void dfs1(int from, int d) {
  dist[from] = d;
  for (int i = 0; i < (int)adj[from].size(); i += 1) {
    int to = adj[from][i];
    if (dist[to] == -1) {
      dfs1(to, d + 1);
    }
  }
}
int main() {
  int n, x, y;
  z = 1;
  flag = true;
  read(n);
  for (int i = 0; i < n; i += 1) {
    read(x, y);
    adj[x].push_back(y);
    adj[y].push_back(x);
    parent[i + 1] = i + 1;
  }
  dfs(1);
  memset(dist, -1, sizeof(dist));
  while (dist[z]) {
    dist[z] = 0;
    z = parent[z];
  }
  for (int i = 1; i < n + 1; i += 1) {
    if (dist[i] == 0) {
      dfs1(i, 0);
    }
  }
  for (int i = 1; i < n + 1; i += 1) cout << dist[i] << ' ';
  cout << endl;
  return 0;
}
