#include <bits/stdc++.h>
using namespace std;
int dist[3005];
bool cycleFound = false;
bool visited[3005];
bool visited2[3005];
int f(int curr, int p, vector<vector<int> > &adj) {
  if (visited[curr]) {
    cycleFound = true;
    return curr;
  } else {
    visited[curr] = true;
    int ma = -1;
    for (int i = 0; i < adj[curr].size(); i++) {
      if (adj[curr][i] != p && !cycleFound) {
        ma = max(ma, f(adj[curr][i], curr, adj));
      }
    }
    if (cycleFound) return ma;
    visited[curr] = false;
    return ma;
  }
}
void fa(int curr, int p, vector<vector<int> > &adj, int fi) {
  if (curr == fi)
    return;
  else {
    visited[curr] = false;
    for (int i = 0; i < adj[curr].size(); i++) {
      if (adj[curr][i] != p) {
        fa(adj[curr][i], curr, adj, fi);
      }
    }
  }
}
void number(int curr, int p, vector<vector<int> > &adj, int x) {
  if (visited[curr]) {
    x = 0;
  }
  dist[curr] = x;
  visited2[curr] = true;
  for (int i = 0; i < adj[curr].size(); i++) {
    if (adj[curr][i] != p && !visited2[adj[curr][i]]) {
      number(adj[curr][i], curr, adj, x + 1);
    }
  }
}
void ini(int n, vector<vector<int> > &adj) {
  int fi = f(1, -1, adj);
  fa(1, -1, adj, fi);
  number(fi, -1, adj, 0);
  for (int i = 1; i <= n; i++) {
    cout << dist[i] << " ";
  }
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 0; i <= n; i++) {
    dist[i] = 0;
    visited[i] = false;
    visited2[i] = false;
  }
  vector<vector<int> > adj(n + 1, vector<int>(0));
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  ini(n, adj);
}
