#include <bits/stdc++.h>   using namespace std;   const int N = 500005;   int n, u, v, cnt = 0, h[N] = {-1}, in[N], out[N], ans[N], val[N], pa[N];   bool chk[N];   vector<int> cur;   vector<int> adj[N];   vector<pair<int, int>> ve;   multiset<int, greater<int>> second, ed, ch[N];   struct segment_tree {     int tr[4 * N], lz[4 * N];     void apply(int i, int v) {       tr[i] += v;       lz[i] += v;     }     void down(int i) {       apply(i * 2, lz[i]);       apply(i * 2 + 1, lz[i]);       lz[i] = 0;     }     void update(int l, int r, int i, int L, int R, int v) {       if (l > R || r < L || L > R) {         return;       } else if (L <= l && r <= R) {         apply(i, v);         return;       } else {         down(i);         update(l, (l + r) / 2, i * 2, L, R, v);         update((l + r) / 2 + 1, r, i * 2 + 1, L, R, v);         tr[i] = max(tr[i * 2], tr[i * 2 + 1]);       }     }     int query(int l, int r, int i, int L, int R) {       if (l > R || r < L || L > R) {         return 0;       } else if (L <= l && r <= R) {         return tr[i];       } else {         down(i);         return max(query(l, (l + r) / 2, i * 2, L, R),                    query((l + r) / 2 + 1, r, i * 2 + 1, L, R));       }     }   } seg;   void DFS(int u, int p = 0) {     h[u] = h[p] + 1;     pa[u] = p;     in[u] = ++cnt;     seg.update(1, n, 1, in[u], in[u], h[u]);     for (int &v : adj[u]) {       if (v != p) {         DFS(v, u);       }     }     out[u] = cnt;   }   void DFS_2(int u, int p = 0) {     int pa =         max(seg.query(1, n, 1, 1, in[u] - 1), seg.query(1, n, 1, out[u] + 1, n));     ve.push_back({0, u});     if (u != 1) {       ve.push_back({pa, u});     }     for (int &v : adj[u]) {       if (v != p) {         int pa = seg.query(1, n, 1, in[v], out[v]);         ve.push_back({pa, u});         seg.update(1, n, 1, 1, n, 1);         seg.update(1, n, 1, in[v], out[v], -2);         DFS_2(v, u);         seg.update(1, n, 1, 1, n, -1);         seg.update(1, n, 1, in[v], out[v], 2);       }     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cin >> n;     for (int i = 1; i < n; i++) {       cin >> u >> v;       adj[u].push_back(v);       adj[v].push_back(u);     }     DFS(1);     DFS_2(1);     for (int i = 1; i <= n; i++) {       second.insert(val[i] = adj[i].size() + 1);     }     for (int i = 1; i <= n; i++) {       for (int &v : adj[i]) {         if (v != pa[i]) {           ch[i].insert(val[v]);         }       }       ed.insert(val[i] + *ch[i].begin() - 2);     }     sort(ve.begin(), ve.end(), greater<pair<int, int>>());     for (int i = 0; i <= n; i += 2) {       ans[i] = max(*second.begin(), *ed.begin());       while (!ve.empty() && ve.back().first == i / 2) {         int u = ve.back().second;         if (!chk[u]) {           chk[u] = true;           cur.push_back(u);         }         ve.pop_back();         second.erase(second.find(val[u]));         second.insert(val[u] - 1);         ed.erase(ed.find(val[u] + *ch[u].begin() - 2));         ed.insert(val[u] - 1 + *ch[u].begin() - 2);         if (u != 1) {           ed.erase(ed.find(val[pa[u]] + *ch[pa[u]].begin() - 2));           ch[pa[u]].erase(ch[pa[u]].find(val[u]));           ch[pa[u]].insert(val[u] - 1);           ed.insert(val[pa[u]] + *ch[pa[u]].begin() - 2);         }         val[u]--;       }       ans[i + 1] = *second.begin();       while (!cur.empty()) {         int u = cur.back();         cur.pop_back();         chk[u] = false;         ans[i + 1] = max(ans[i + 1], val[u] + 1);       }     }     for (int i = 1; i <= n; i++) {       cout << max(ans[i], 1) <<    ;     }   }