#include <bits/stdc++.h>
using namespace std;
vector<int> color;
vector<vector<int>> v;
vector<int> parent;
int start, finish;
int findCycle(int a) {
  color[a] = 1;
  for (int i = 0; i < v[a].size(); i++) {
    if (color[v[a][i]] == 0) {
      parent[v[a][i]] = a;
      if (findCycle(v[a][i]) == 1) {
        return 1;
      }
    } else if (color[v[a][i]] == 1 && parent[a] != v[a][i]) {
      finish = v[a][i];
      start = a;
      return 1;
    }
  }
  color[a] = 2;
  return 0;
}
void dfsLevel(int a, int level) {
  color[a] = level;
  for (int i = 0; i < v[a].size(); i++) {
    if (color[v[a][i]] == -1) {
      dfsLevel(v[a][i], level + 1);
    }
  }
}
int main() {
  int n, a, b;
  cin >> n;
  v.resize(n);
  color.resize(n, 0);
  parent.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    v[a - 1].push_back(b - 1);
    v[b - 1].push_back(a - 1);
  }
  findCycle(0);
  for (int i = 0; i < v.size(); i++) {
    color[i] = -1;
  }
  while (start != finish) {
    color[start] = 0;
    start = parent[start];
  }
  color[finish] = 0;
  for (int i = 0; i < v.size(); i++) {
    if (color[i] == 0) {
      dfsLevel(i, 0);
    }
  }
  for (int i = 0; i < v.size(); i++) {
    cout << ' ' << color[i];
  }
  return 0;
}
