#include <bits/stdc++.h>
using namespace std;
bool vis[3001];
vector<vector<int> > adj(3001);
int dist[3001];
int inCycle[3001];
int findCycle(int s, int p, int x) {
  if (vis[s]) return 0;
  vis[s] = 1;
  int ans = 0;
  for (int i = 0; i < adj[s].size(); i++) {
    if (adj[s][i] == x && (adj[s][i] != p)) {
      return 1;
    }
    ans = ans | findCycle(adj[s][i], s, x);
  }
  return (ans);
}
void distance(int s, int p, int x) {
  vis[s] = 1;
  dist[s] = x;
  for (int i = 0; i < adj[s].size(); i++) {
    if ((adj[s][i] != p) && (inCycle[adj[s][i]] == 0)) {
      distance(adj[s][i], s, x + 1);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, x, y;
  scanf("%d", &n);
  for (int i = 0; i <= 3000; i++) vis[i] = inCycle[i] = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &x, &y);
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) vis[j] = 0;
    inCycle[i] = findCycle(i, 0, i);
  }
  for (int i = 1; i <= n; i++) {
    if (inCycle[i] == 1) {
      distance(i, 0, 0);
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << dist[i] << " ";
  }
  cout << endl;
  return 0;
}
