#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;

const int N = 2e5 + 10;

int n, ans[N], timer;
bool diametr[N];
vector <int> g[N];

pair<int, int> dfs1(int u, int p) {
  pair<int, int> tmp = {0, u}, cur;
  for (int to : g[u]) {
    if (to == p) continue;
    cur = dfs1(to, u);
    tmp = max(tmp, {cur.fi + 1, cur.se});
  }
  return tmp;
}

bool dfs2(int u, int p, int x) {
  diametr[u] = true;
  if (u == x) return true;
  for (int to : g[u]) {
    if (to == p) continue;
    if (dfs2(to, u, x))
      return true;
  }
  return false;
  diametr[u] = false;
}

void dfs3(int u, int p) {
  ans[u] = ++timer;
  for (int to : g[u])
    if (to != p && !diametr[to]) dfs3(to, u);
  for (int to : g[u])
    if (to != p && diametr[to]) dfs3(to, u);
  timer++;
}

main(){
  //freopen("input.txt", "r", stdin);
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    g[u].pb(v);
    g[v].pb(u);
  }
  int t1, t2;
  pair<int, int> tmp;
  tmp = dfs1(1, -1); t1 = tmp.se;
  tmp = dfs1(t1, -1); t2 = tmp.se;
  dfs2(t1, -1, t2);
  dfs3(t1, -1);
  for (int i = 1; i <= n; i++)
    printf("%d ", ans[i]);
}

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr double EPS = 1e-8;
constexpr int MOD = 1000000007;
// constexpr int MOD = 998244353;
constexpr int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
constexpr int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n; cin >> n;
  vector<int> a(n + 1, 1);
  FOR(i, 1, n + 1) for (int j = i * 2; j <= n; j += i) chmax(a[j], a[i] + 1);
  // FOR(i, 1, n + 1) FOR(j, i + 1, n + 1) {
  //   if (j % i == 0) assert(a[i] != a[j]);
  // }
  FOR(i, 1, n + 1) cout << a[i] << " \n"[i == n];
  return 0;
}
