#include <bits/stdc++.h>
using namespace std;
vector<int> v[3005];
vector<int> visited[3005];
unordered_map<int, int> mp;
int d[3005][3005], vis[3005];
void dfs(int x, int par) {
  for (int y : v[x]) {
    if (y == par) continue;
    if (!visited[y].size()) {
      visited[y] = visited[x];
      visited[y].push_back(y);
      dfs(y, x);
    } else if (visited[y].size()) {
      if (mp.empty()) {
        for (int mem : visited[x]) mp[mem] = 1;
        for (int mem : visited[y])
          if (mp[mem]) mp[mem] = 0;
        mp[y] = 1;
      }
    }
  }
}
int main() {
  memset(d, -1, sizeof d);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  visited[1].push_back(1);
  dfs(1, -1);
  for (int i = 1; i <= n; i++)
    if (mp[i]) {
      memset(vis, 0, sizeof vis);
      d[i][i] = 0;
      queue<int> q;
      q.push(i);
      while (!q.empty()) {
        int ttop = q.front();
        q.pop();
        vis[ttop] = 1;
        for (int y : v[ttop]) {
          if (!vis[y]) {
            d[i][y] = d[i][ttop] + 1;
            q.push(y);
          }
        }
      }
    }
  for (int i = 1; i <= n; i++) {
    if (!mp[i]) {
      int minn = 3005;
      for (int j = 1; j <= n; j++) {
        if (d[j][i] < minn && d[j][i] != -1) minn = d[j][i];
      }
      cout << minn << " ";
    } else
      cout << 0 << " ";
  }
}
