#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const int BUFFER_SIZE = 1 << 18;
const int INF = 1 << 30;
const long long LINF = 1ll << 60;
char BUFFER[BUFFER_SIZE];
int gi() {
  int x;
  scanf("%d", &x);
  return x;
}
double gd() {
  double x;
  scanf("%lf", &x);
  return x;
}
long long gll() {
  long long x;
  cin >> x;
  return x;
}
vector<int> gvi(int n) {
  vector<int> a;
  while (n--) a.push_back(gi());
  return a;
}
string gs() {
  scanf("%s", BUFFER);
  return string(BUFFER);
}
istringstream buff() { return istringstream(string(BUFFER)); }
template <class T>
struct forArray {
  T* a;
  int n;
  forArray(T* a, int n) : a(a), n(n) {}
};
template <class A, class B>
ostream& operator<<(ostream& os, const pair<A, B>& d);
template <class T>
ostream& operator<<(ostream& os, const vector<T>& d);
template <class T>
ostream& operator<<(ostream& os, const queue<T>& d);
template <class T>
ostream& operator<<(ostream& os, const stack<T>& d);
template <class T>
ostream& operator<<(ostream& os, const set<T>& d);
template <class T>
ostream& operator<<(ostream& os, const multiset<T>& d);
template <class T>
ostream& operator<<(ostream& os, const unordered_set<T>& d);
template <class A, class B>
ostream& operator<<(ostream& os, const map<A, B>& d);
template <class A, class B>
ostream& operator<<(ostream& os, const multimap<A, B>& d);
template <class A, class B>
ostream& operator<<(ostream& os, const unordered_map<A, B>& d);
template <class T>
ostream& operator<<(ostream& os, const vector<T>& d) {
  os << "[";
  int f = 0;
  for (auto x : d) {
    if (f) os << ",";
    f = 1;
    os << x;
  }
  return os << "]";
};
template <class T>
ostream& operator<<(ostream& os, const queue<T>& d) {
  os << "[";
  int f = 0;
  for (auto x : d) {
    if (f) os << ",";
    f = 1;
    os << x;
  }
  return os << "]";
};
template <class T>
ostream& operator<<(ostream& os, const stack<T>& d) {
  os << "[";
  int f = 0;
  for (auto x : d) {
    if (f) os << ",";
    f = 1;
    os << x;
  }
  return os << "]";
};
template <class T>
ostream& operator<<(ostream& os, const set<T>& d) {
  os << "[";
  int f = 0;
  for (auto x : d) {
    if (f) os << ",";
    f = 1;
    os << x;
  }
  return os << "]";
};
template <class T>
ostream& operator<<(ostream& os, const multiset<T>& d) {
  os << "[";
  int f = 0;
  for (auto x : d) {
    if (f) os << ",";
    f = 1;
    os << x;
  }
  return os << "]";
};
template <class T>
ostream& operator<<(ostream& os, const unordered_set<T>& d) {
  os << "[";
  int f = 0;
  for (auto x : d) {
    if (f) os << ",";
    f = 1;
    os << x;
  }
  return os << "]";
};
template <class A, class B>
ostream& operator<<(ostream& os, const map<A, B>& d) {
  os << "[";
  int f = 0;
  for (auto x : d) {
    if (f) os << ",";
    f = 1;
    os << x;
  }
  return os << "]";
};
template <class A, class B>
ostream& operator<<(ostream& os, const multimap<A, B>& d) {
  os << "[";
  int f = 0;
  for (auto x : d) {
    if (f) os << ",";
    f = 1;
    os << x;
  }
  return os << "]";
};
template <class A, class B>
ostream& operator<<(ostream& os, const unordered_map<A, B>& d) {
  os << "[";
  int f = 0;
  for (auto x : d) {
    if (f) os << ",";
    f = 1;
    os << x;
  }
  return os << "]";
};
template <class T>
ostream& operator<<(ostream& os, const forArray<T>& d) {
  os << "[";
  for (int i = 0; i < d.n; ++i) {
    if (i) os << ",";
    os << d.a[i];
  }
  return os << "]";
}
template <class A, class B>
ostream& operator<<(ostream& os, const pair<A, B>& d) {
  return os << "[" << d.first << ", " << d.second << "]";
}
int P[3333];
int was[3333];
vector<vector<int> > G;
set<int> loop;
void dfs(int x, int p = -1) {
  was[x] = 1;
  P[x] = p;
  for (int y : G[x]) {
    if (y != p) {
      if (was[y]) {
        if (!loop.size()) {
          loop.insert(y);
          int c = x;
          while (c != y) {
            loop.insert(c);
            c = P[c];
          }
        }
      } else {
        dfs(y, x);
      }
    }
  }
}
int D[3333];
void dfs2(int x, int d = 0) {
  if (D[x] != -1) return;
  if (loop.count(x))
    D[x] = 0;
  else
    D[x] = d;
  for (int y : G[x]) dfs2(y, D[x] + 1);
}
int main() {
  int n = gi();
  G = vector<vector<int> >(n);
  for (int i = 0; i < n; ++i) {
    int a = gi() - 1;
    int b = gi() - 1;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  memset((was), (0), sizeof(was));
  memset((D), (-1), sizeof(D));
  dfs(0);
  dfs2(*loop.begin());
  for (int i = 0; i < n; ++i) printf("%d%c", D[i], i + 1 == n ? '\n' : ' ');
  return 0;
}
