#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
vector<int> g[500001];
vector<pii> ret[500001];
vector<int> ret2[500001];
vector<pii> maxai[500001];

int ans[500002];

int dfs(int v, int p){
    vector<int> toLeave;

    for(int i:g[v]){
        if(i==p){
            toLeave.push_back(i);
            continue;
        }
        ret[v].push_back({dfs(i, v),i});
        ret2[v].push_back(ret[v].back().first);

        maxai[v].push_back(ret[v].back());
        sort(maxai[v].rbegin(), maxai[v].rend());
        if(maxai[v].size()>2){
            maxai[v].pop_back();
        }
    }
    int cnt = 0;
    if(maxai[v].size()>0&&!(maxai[v].size()==1&&maxai[v][0].second==p)){
        cnt = maxai[v][0].first;
        if(maxai[v][0].second==p){
            cnt=maxai[v][1].first;
        }
    }
    g[v]=toLeave;
    return cnt+1;
}

int ind[500001];
unordered_map<int, int, custom_hash> tried[500001];

int main()
{
    int n; scanf("%d", &n);

    vector<pii> edges;

    for(int i=1; i<=n-1; i++){
        int u, v; scanf("%d %d", &u, &v);
        g[u].push_back(v);
        g[v].push_back(u);
        edges.push_back({u,v});
    }
    for(int i=1; i<=n; i++){
        ans[i]=1;
        ans[1] = max(ans[1], (int)g[i].size()+1);
    }

    map<vector<int>, int> mp;

    for(int i=1; i<=n; i++){
        dfs(i,i);
        sort(ret2[i].rbegin(), ret2[i].rend());
        for(int j=1; j<ret2[i].size(); j++){
            int pirmas = ret2[i][j];
            int antras = ret2[i][j-1];
            if(pirmas==antras){
                ans[pirmas*2]=max(ans[pirmas*2], j+1);
            }
            else{
                ans[pirmas*2+1]=max(ans[pirmas*2+1], j+1);
            }
        }
        if(!mp.count(ret2[i])){
            mp[ret2[i]]=mp.size();
            ind[i]=mp.size();
        }
        else{
            ind[i]=mp[ret2[i]];
        }

    }
    for(int i=n-1; i>=1; i--){
        ans[i]=max(ans[i], ans[i+1]);
    }
    for(pii i:edges){
        int pirmas = ind[i.first];
        int antras = ind[i.second];
        if(tried[pirmas].count(antras)){
            continue;
        }
        tried[pirmas][antras]=1;
        tried[antras][pirmas]=1;
        vector<int> newret;
        for(pii j:ret[i.first]){
            if(j.second!=i.second){
                newret.push_back(j.first);
            }
        }
        for(pii j:ret[i.second]){
            if(j.second!=i.first){
                newret.push_back(j.first);
            }
        }
        sort(newret.rbegin(), newret.rend());
        for(int j=1; j<newret.size(); j++){
            ans[newret[j]*2] = max(ans[newret[j]*2], j+1);
        }
    }

    for(int i=n-1; i>=1; i--){
        ans[i]=max(ans[i], ans[i+2]);
    }
    for(int i=1; i<=n; i++){
        printf("%d ", ans[i]);
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

vector<int> g[500001];
vector<pii> ret[500001];
vector<int> ret2[500001];
vector<pii> maxai[500001];

int ans[500002];

int dfs(int v, int p){
    vector<int> toLeave;

    for(int i:g[v]){
        if(i==p){
            toLeave.push_back(i);
            continue;
        }
        ret[v].push_back({dfs(i, v),i});
        ret2[v].push_back(ret[v].back().first);

        maxai[v].push_back(ret[v].back());
        sort(maxai[v].rbegin(), maxai[v].rend());
        if(maxai[v].size()>2){
            maxai[v].pop_back();
        }
    }
    int cnt = 0;
    if(maxai[v].size()>0&&!(maxai[v].size()==1&&maxai[v][0].second==p)){
        cnt = maxai[v][0].first;
        if(maxai[v][0].second==p){
            cnt=maxai[v][1].first;
        }
    }
    g[v]=toLeave;
    return cnt+1;
}

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n; cin>>n;

    vector<pii> edges;

    for(int i=1; i<=n-1; i++){
        int u, v; cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
        edges.push_back({u,v});
    }
    for(int i=1; i<=n; i++){
        ans[i]=1;
        ans[1] = max(ans[1], (int)g[i].size()+1);
    }

    map<vector<int>, int> mp;

    for(int i=1; i<=n; i++){
        dfs(i,i);
        sort(ret2[i].rbegin(), ret2[i].rend());
        for(int j=1; j<ret2[i].size(); j++){
            int pirmas = ret2[i][j];
            int antras = ret2[i][j-1];
            if(pirmas==antras){
                ans[pirmas*2]=max(ans[pirmas*2], j+1);
            }
            else{
                ans[pirmas*2+1]=max(ans[pirmas*2+1], j+1);
            }
        }
        if(!mp.count(ret2[i])){
            mp[ret2[i]]=mp.size();
        }

    }
    for(int i=n-1; i>=1; i--){
        ans[i]=max(ans[i], ans[i+1]);
    }
    set<pii> tried;
    for(pii i:edges){
        int pirmas = mp[ret2[i.first]];
        int antras = mp[ret2[i.second]];
        if(tried.count({pirmas, antras})){
            continue;
        }
        tried.insert({pirmas,antras});
        tried.insert({antras,pirmas});
        vector<int> newret;
        for(pii j:ret[i.first]){
            if(j.second!=i.second){
                newret.push_back(j.first);
            }
        }
        for(pii j:ret[i.second]){
            if(j.second!=i.first){
                newret.push_back(j.first);
            }
        }
        sort(newret.rbegin(), newret.rend());
        for(int j=1; j<newret.size(); j++){
            ans[newret[j]*2] = max(ans[newret[j]*2], j+1);
        }
    }

    for(int i=n-1; i>=1; i--){
        ans[i]=max(ans[i], ans[i+2]);
    }
    for(int i=1; i<=n; i++){
        cout<<ans[i]<<' ';
    }
    return 0;
}


#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
struct Edge
{
	int to;
	int nxt;
}e[1000005];
struct Node
{
	int dep;
	int in;
}tmp[1000005];
int n,m,edgenum,head[500005],pa[500005],dep[500005],d[500005],max1[500005],max2[500005],ans[500005];
int a[500005],top,_f[2000005],*f[2000005],tot;
int num[500005];
priority_queue<int>q,del;
bool cmp(Node a,Node b)
{
	return a.dep<b.dep;
}
void add(int u,int v)
{
	e[++edgenum].to=v;
	e[edgenum].nxt=head[u];
	head[u]=edgenum;
}
void dfs1(int node)
{
	f[node]=_f+tot;
	tot+=d[node]+2;
	dep[node]=dep[pa[node]]+1;
	for(int hd=head[node];hd;hd=e[hd].nxt)
	{
		int to=e[hd].to;
		if(to==pa[node])continue;
		pa[to]=node;
		dfs1(to);
		if(max1[to]+1>max1[node])
		{
			max2[node]=max1[node];
			max1[node]=max1[to]+1;
		}
		else if(max1[to]+1>max2[node])
		  max2[node]=max1[to]+1;
	}
}
void dfs2(int node)
{
	top=0;
	for(int hd=head[node];hd;hd=e[hd].nxt)
	{
		int to=e[hd].to;
		if(to==pa[node])continue;
		a[++top]=max1[to]+1;
	}
	if(pa[node])
	{
		if(max1[pa[node]]==max1[node]+1)a[++top]=max2[pa[node]]+1;
		else a[++top]=max1[pa[node]]+1;
	}
	a[++top]=0;
	sort(a+1,a+top+1);
	for(int i=1;i<=top;i++)f[node][top-i+1]=a[i];
	for(int i=1;i<=top;i++)
	{
		ans[f[node][i]*2]=max(ans[f[node][i]*2],i);
		if(f[node][i-1]!=f[node][i])ans[f[node][i]*2+1]=max(ans[f[node][i]*2+1],i);
	}
//	printf("%d:max1=%d,max2=%d\n",node,max1[node],max2[node]);
//	for(int i=1;i<=top;i++)printf("%d ",a[i]);
//	printf("\n");
//	for(int i=1;i<=d[node]+1;i++)printf("%d ",f[node][i]);
//	printf("\n");
	top=0;
	for(int hd=head[node];hd;hd=e[hd].nxt)
	{
		int to=e[hd].to;
		if(to==pa[node])
		{
			tmp[++top].in=node;
			if(max1[pa[node]]==max1[node]+1)tmp[top].dep=max2[pa[node]]+1;
			else tmp[top].dep=max1[pa[node]]+1;
			continue;
		}
		tmp[++top].in=node;
		tmp[top].dep=max1[to]+1;
		for(int hd=head[to];hd;hd=e[hd].nxt)
		{
			int to2=e[hd].to;
			if(to2==node)continue;
			tmp[++top].in=to;
			tmp[top].dep=max1[to2]+1;
		}
	}
	while(!q.empty()) q.pop();
	while(!del.empty()) del.pop();
	sort(tmp+1,tmp+top+1,cmp);
	num[node]=d[node];
	for(int hd=head[node];hd;hd=e[hd].nxt)
	{
		int to=e[hd].to;
		if(to==pa[node])continue;
		num[to]=d[to]-1;
		q.push(num[to]);
	}
	for(int i=1;i<=top;i++)
	{
		if(tmp[i].in==node)
		{
			while(!q.empty()&&!del.empty()&&q.top()==del.top())q.pop(),del.pop();
			if(q.empty())continue;
			ans[tmp[i].dep*2]=max(ans[tmp[i].dep*2],num[node]-1+q.top());
			num[node]--;
		}
		else
		{
			ans[tmp[i].dep*2]=max(ans[tmp[i].dep*2],num[node]-1+num[tmp[i].in]);
			del.push(num[tmp[i].in]);
			num[tmp[i].in]--;
			if(num[tmp[i].in])q.push(num[tmp[i].in]);
		}
	}
	if(pa[node])
	{
		int v=0;
		if(max1[node]+1==max1[pa[node]])v=max2[pa[node]];
		else v=max1[pa[node]];
		if(v+1>max1[node])
		{
			max2[node]=max1[node];
			max1[node]=v+1;
		}
		else if(v+1>max2[node])
		  max2[node]=v+1;
	}
	for(int hd=head[node];hd;hd=e[hd].nxt)
	{
		int to=e[hd].to;
		if(to==pa[node])continue;
		dfs2(to);
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		add(u,v);
		add(v,u);
		d[u]++,d[v]++;
	}
	for(int i=1;i<=n;i++)ans[i]=1;
	dfs1(1);
	dfs2(1);
	for(int i=n;i>=1;i--)ans[i]=max(ans[i],ans[i+1]);
	for(int i=1;i<=n;i++)printf("%d ",ans[i]);
	printf("\n");
	return 0;
}


#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
#define lson o<<1
#define rson o<<1|1
#define mid (l+r)/2
using namespace std;
int maxv[2000005];
void update(int o,int l,int r,int from,int to,int v)
{
	if(from>to)return;
	if(l>=from&&r<=to)
	{
		maxv[o]=max(maxv[o],v);
		return;
	}
	if(from<=mid)update(lson,l,mid,from,to,v);
	if(to>mid)update(rson,mid+1,r,from,to,v);
}
int query(int o,int l,int r,int p)
{
	int ans=maxv[o];
	if(l==r)return ans;
	if(p<=mid)ans=max(ans,query(lson,l,mid,p));
	else ans=max(ans,query(rson,mid+1,r,p));
	return ans;
}
struct Edge
{
	int to;
	int nxt;
}e[1000005];
struct Node
{
	int dep;
	int in;
}tmp[1000005];
int n,m,edgenum,head[500005],pa[500005],dep[500005],d[500005],max1[500005],max2[500005],ans[500005];
int a[500005],top,_f[2000005],*f[2000005],tot;
int num[500005];
priority_queue<int>q,del;
bool cmp(Node a,Node b)
{
	return a.dep<b.dep;
}
void add(int u,int v)
{
	e[++edgenum].to=v;
	e[edgenum].nxt=head[u];
	head[u]=edgenum;
}
void dfs1(int node)
{
	f[node]=_f+tot;
	tot+=d[node]+2;
	dep[node]=dep[pa[node]]+1;
	for(int hd=head[node];hd;hd=e[hd].nxt)
	{
		int to=e[hd].to;
		if(to==pa[node])continue;
		pa[to]=node;
		dfs1(to);
		if(max1[to]+1>max1[node])
		{
			max2[node]=max1[node];
			max1[node]=max1[to]+1;
		}
		else if(max1[to]+1>max2[node])
		  max2[node]=max1[to]+1;
	}
}
void dfs2(int node)
{
	top=0;
	for(int hd=head[node];hd;hd=e[hd].nxt)
	{
		int to=e[hd].to;
		if(to==pa[node])continue;
		a[++top]=max1[to]+1;
	}
	if(pa[node])
	{
		if(max1[pa[node]]==max1[node]+1)a[++top]=max2[pa[node]]+1;
		else a[++top]=max1[pa[node]]+1;
	}
	a[++top]=0;
	sort(a+1,a+top+1);
	for(int i=1;i<=top;i++)f[node][top-i+1]=a[i];
	for(int i=1;i<=top;i++)
	{
		ans[f[node][i]*2]=max(ans[f[node][i]*2],i);
		if(f[node][i-1]!=f[node][i])ans[f[node][i]*2+1]=max(ans[f[node][i]*2+1],i);
	}
//	printf("%d:max1=%d,max2=%d\n",node,max1[node],max2[node]);
//	for(int i=1;i<=top;i++)printf("%d ",a[i]);
//	printf("\n");
//	for(int i=1;i<=d[node]+1;i++)printf("%d ",f[node][i]);
//	printf("\n");
	top=0;
	for(int hd=head[node];hd;hd=e[hd].nxt)
	{
		int to=e[hd].to;
		if(to==pa[node])
		{
			tmp[++top].in=node;
			if(max1[pa[node]]==max1[node]+1)tmp[top].dep=max2[pa[node]]+1;
			else tmp[top].dep=max1[pa[node]]+1;
			continue;
		}
		tmp[++top].in=node;
		tmp[top].dep=max1[to]+1;
		for(int hd=head[to];hd;hd=e[hd].nxt)
		{
			int to2=e[hd].to;
			if(to2==node)continue;
			tmp[++top].in=to;
			tmp[top].dep=max1[to2]+1;
		}
	}
	while(!q.empty()) q.pop();
	while(!del.empty()) del.pop();
	sort(tmp+1,tmp+top+1,cmp);
	num[node]=d[node];
	for(int hd=head[node];hd;hd=e[hd].nxt)
	{
		int to=e[hd].to;
		if(to==pa[node])continue;
		num[to]=d[to]-1;
		q.push(num[to]);
	}
	for(int i=1;i<=top;i++)
	{
		if(tmp[i].in==node)
		{
			while(!q.empty()&&!del.empty()&&q.top()==del.top())q.pop(),del.pop();
			if(q.empty())continue;
			update(1,1,n,1,tmp[i].dep,num[node]-1+q.top());
			num[node]--;
		}
		else
		{
			update(1,1,n,1,tmp[i].dep,num[node]-1+num[tmp[i].in]);
			del.push(num[tmp[i].in]);
			num[tmp[i].in]--;
			if(num[tmp[i].in])q.push(num[tmp[i].in]);
		}
	}
	if(pa[node])
	{
		int v=0;
		if(max1[node]+1==max1[pa[node]])v=max2[pa[node]];
		else v=max1[pa[node]];
		if(v+1>max1[node])
		{
			max2[node]=max1[node];
			max1[node]=v+1;
		}
		else if(v+1>max2[node])
		  max2[node]=v+1;
	}
	for(int hd=head[node];hd;hd=e[hd].nxt)
	{
		int to=e[hd].to;
		if(to==pa[node])continue;
		dfs2(to);
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		add(u,v);
		add(v,u);
		d[u]++,d[v]++;
	}
	for(int i=1;i<=n;i++)ans[i]=1;
	dfs1(1);
	dfs2(1);
	for(int i=n;i>=1;i--)ans[i]=max(ans[i],ans[i+1]);
	for(int i=1;i<=n;i++)
	{
		if(i&1)printf("%d ",ans[i]);
		else printf("%d ",max(ans[i],query(1,1,n,i/2)));
	}
	return 0;
}


#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
#define lson o<<1
#define rson o<<1|1
#define mid (l+r)/2
using namespace std;
int maxv[2000005];
void update(int o,int l,int r,int from,int to,int v)
{
	if(from>to)return;
	if(l>=from&&r<=to)
	{
		maxv[o]=max(maxv[o],v);
		return;
	}
	if(from<=mid)update(lson,l,mid,from,to,v);
	if(to>mid)update(rson,mid+1,r,from,to,v);
}
int query(int o,int l,int r,int p)
{
	int ans=maxv[o];
	if(l==r)return ans;
	if(p<=mid)ans=max(ans,query(lson,l,mid,p));
	else ans=max(ans,query(rson,mid+1,r,p));
	return ans;
}
struct Edge
{
	int to;
	int nxt;
}e[1000005];
struct Node
{
	int dep;
	int in;
}tmp[1000005];
int n,m,edgenum,head[500005],pa[500005],dep[500005],d[500005],max1[500005],max2[500005];
int a[500005],top,_f[2000005],*f[2000005],tot;
int num[500005];
priority_queue<int>q,del;
bool cmp(Node a,Node b)
{
	return a.dep<b.dep;
}
void add(int u,int v)
{
	e[++edgenum].to=v;
	e[edgenum].nxt=head[u];
	head[u]=edgenum;
}
void dfs1(int node)
{
	f[node]=_f+tot;
	tot+=d[node]+2;
	dep[node]=dep[pa[node]]+1;
	for(int hd=head[node];hd;hd=e[hd].nxt)
	{
		int to=e[hd].to;
		if(to==pa[node])continue;
		pa[to]=node;
		dfs1(to);
		if(max1[to]+1>max1[node])
		{
			max2[node]=max1[node];
			max1[node]=max1[to]+1;
		}
		else if(max1[to]+1>max2[node])
		  max2[node]=max1[to]+1;
	}
}
void dfs2(int node)
{
	top=0;
	for(int hd=head[node];hd;hd=e[hd].nxt)
	{
		int to=e[hd].to;
		if(to==pa[node])continue;
		a[++top]=max1[to]+1;
	}
	if(pa[node])
	{
		if(max1[pa[node]]==max1[node]+1)a[++top]=max2[pa[node]]+1;
		else a[++top]=max1[pa[node]]+1;
	}
	a[++top]=0;
	sort(a+1,a+top+1);
	for(int i=1;i<=top;i++)f[node][top-i+1]=a[i];
	for(int i=1;i<=top;i++)
	{
		update(1,1,n,1,f[node][i]*2,i);
		if(f[node][i-1]!=f[node][i])
		  update(1,1,n,1,f[node][i]*2+1,i);
	}
//	printf("%d:max1=%d,max2=%d\n",node,max1[node],max2[node]);
//	for(int i=1;i<=top;i++)printf("%d ",a[i]);
//	printf("\n");
//	for(int i=1;i<=d[node]+1;i++)printf("%d ",f[node][i]);
//	printf("\n");
	top=0;
	for(int hd=head[node];hd;hd=e[hd].nxt)
	{
		int to=e[hd].to;
		if(to==pa[node])
		{
			tmp[++top].in=node;
			if(max1[pa[node]]==max1[node]+1)tmp[top].dep=max2[pa[node]]+1;
			else tmp[top].dep=max1[pa[node]]+1;
			continue;
		}
		tmp[++top].in=node;
		tmp[top].dep=max1[to]+1;
		for(int hd=head[to];hd;hd=e[hd].nxt)
		{
			int to2=e[hd].to;
			if(to2==node)continue;
			tmp[++top].in=to;
			tmp[top].dep=max1[to2]+1;
		}
	}
	while(!q.empty()) q.pop();
	while(!del.empty()) del.pop();
	sort(tmp+1,tmp+top+1,cmp);
	num[node]=d[node];
	for(int hd=head[node];hd;hd=e[hd].nxt)
	{
		int to=e[hd].to;
		if(to==pa[node])continue;
		num[to]=d[to]-1;
		q.push(num[to]);
	}
	for(int i=1;i<=top;i++)
	{
		if(tmp[i].in==node)
		{
			while(!q.empty()&&!del.empty()&&q.top()==del.top())q.pop(),del.pop();
			if(q.empty())continue;
			update(1,1,n,2,tmp[i].dep*2,num[node]-1+q.top());
			num[node]--;
		}
		else
		{
			update(1,1,n,2,tmp[i].dep*2,num[node]-1+num[tmp[i].in]);
			del.push(num[tmp[i].in]);
			num[tmp[i].in]--;
			if(num[tmp[i].in])q.push(num[tmp[i].in]);
		}
	}
	if(pa[node])
	{
		int v=0;
		if(max1[node]+1==max1[pa[node]])v=max2[pa[node]];
		else v=max1[pa[node]];
		if(v+1>max1[node])
		{
			max2[node]=max1[node];
			max1[node]=v+1;
		}
		else if(v+1>max2[node])
		  max2[node]=v+1;
	}
	for(int hd=head[node];hd;hd=e[hd].nxt)
	{
		int to=e[hd].to;
		if(to==pa[node])continue;
		dfs2(to);
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		add(u,v);
		add(v,u);
		d[u]++,d[v]++;
	}
	dfs1(1);
	dfs2(1);
	for(int i=1;i<=n;i++)printf("%d ",max(query(1,1,n,i),1));
	printf("\n");
	return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;

const int N = 500500;
vector<int> f[N];
int tmp[N];
int g[N];
int h[N]; // largest length which is greater than j
int ans[N];
vector<int> adj[N];
int zero = 0;
int n;

int& dp(const int& i, const int& j) {
    zero = 0;
    if (j>g[i]) return zero;
    return f[i][g[i]-j];
}

void dfs(int u, int p, int hei) {
    pii best(0, 0);
    for (auto& v : adj[u]) {
        if (v == p) continue;
        dfs(v, u, hei+1);
        best = max(best, pii(g[v], v));
    }

    ans[1] = max(ans[1], (int) adj[u].size()+1);

    int q = -1;
    for (auto& v : adj[u]) {
        if (v == p) continue;
        if (v == best.second) continue;
        for (int i=0; i<=g[v]; ++i) {
            tmp[i+1]++;
        }
        q = max(g[v], q);
    }

    ans[best.first+q+2] = max(ans[best.first+q+2], 2);
    ans[best.first+q+1] = max(ans[best.first+q+1], 2);

    for (int i=1; i<=min(q+1, g[best.second]); ++i) {
        ans[i*2] = max(ans[i*2], tmp[i]+dp(best.second, i)+(hei-1 >= i));
    }

    f[u] = move(f[best.second]);
    g[u] = g[best.second];

    for (int i=0; i<=h[best.second]; ++i) {
        dp(u, i) = 1;
    }
    g[u]++;
    f[u].push_back(0);
    for (int i=1; i<=q+1; ++i) {
        dp(u, i) += tmp[i];
        tmp[i] = 0;
    }
    h[u] = q+1;

    for (auto& v : adj[u]) {
        if (v == p) continue;
        if (v == best.second) continue;
        for (int i=1; i<=g[v]; ++i) {
            ans[i*2] = max(ans[i*2], dp(v, i)+dp(u, i)-1+(hei-1 >= i));
        }
    }

    for (int i=1; i<=q; ++i) {
        int ic = dp(u, i) + (hei-1 >= i);
        int ipc = dp(u, i+1) + (hei-1 >= i+1);
        ans[i*2] = max(ans[i*2], ic);
        ans[i*2+1] = max(ans[i*2+1], ipc + (ic > ipc));
    }

    //cerr << " : " << u << " " << g[u]+hei-1 << " " << g[u] << endl;
    ans[g[u]+hei-1] = max(ans[g[u]+hei-1], 2);
    ans[g[u]+hei-2] = max(ans[g[u]+hei-2], 2);
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> n;
    for (int i=0; i<=n; ++i) {
        h[i] = g[i] = -1;
    }
    for (int i=1; i<=n-1; ++i) {
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
        ans[i] = 1;
    }
    ans[n] = 1;
    dfs(1, -1, 1);
    for (int i=1; i<=n; ++i) {
        cout << ans[i] << " ";
    }
    cout << "\n";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;

const int N = 500500;
vector<int> f[N];
int tmp[N];
int g[N];
int h[N]; // largest length which is greater than j
int ans[N];
int hh[N]; // height of subtree
int lon[N]; // longest path through parent
vector<int> adj[N];
int zero = 0;
int b2 = 0;
int n;

int& dp(const int& i, const int& j) {
    zero = 0;
    if (j>g[i]) return zero;
    return f[i][g[i]-j];
}

struct max2 {
    int first, second;
    max2() : first(-1), second(-1) {}
    void insert(int x) {
        if (x > first) {
            swap(first, second); first = x;
        } else if (x > second) {
            second = x;
        }
    }
    int other(int x) {
        return (x == first ? second : first);
    }
};

void prep(int u, int p, int hei) {
    ////cerr << " HH " << u << " " << hei << endl;
    hh[u] = hei;
    max2 m2;
    for (auto& v : adj[u]) {
        if (v == p) continue;
        prep(v, u, hei+1);
        ////cerr << "     INSERT " << v << " " << hh[v] << endl;
        m2.insert(hh[v]);
        hh[u] = max(hh[u], hh[v]);
    }
    for (auto& v : adj[u]) {
        if (v == p) continue;
        ////cerr << " UP " << v << " : " << m2.other(hh[v])-hei+1 << " :: " << m2.other(hh[v]) << " -- " << m2.first << " " << m2.second << endl;
        lon[v] = max(hei-1, m2.other(hh[v])-hei+1);
    }
}

void prep2(int u, int p, int b) {
    lon[u] = max(lon[u], b);
    for (auto& v : adj[u]) {
        if (v == p) continue;
        prep2(v, u, lon[u]+1);
    }
}

void dfs(int u, int p, int hei) {
    pii best(0, 0);
    for (auto& v : adj[u]) {
        if (v == p) continue;
        dfs(v, u, hei+1);
        best = max(best, pii(g[v], v));
    }

    ans[1] = max(ans[1], (int) adj[u].size()+1);

    int q = -1;
    for (auto& v : adj[u]) {
        if (v == p) continue;
        if (v == best.second) continue;
        for (int i=0; i<=g[v]; ++i) {
            tmp[i+1]++;
        }
        q = max(g[v], q);
    }

    //cerr << " ::::: " << u << endl;

    b2 = max((int) best.first+q+2, b2);
    /*
    ans[best.first+q+2] = max(ans[best.first+q+2], 2);
    ans[best.first+q+1] = max(ans[best.first+q+1], 2);
    */

    for (int i=1; i<=min(q+1, g[best.second]); ++i) {
        ans[i*2] = max(ans[i*2], tmp[i]+dp(best.second, i)+(lon[u]>= i));
    }

    f[u] = move(f[best.second]);
    g[u] = g[best.second];

    for (int i=0; i<=h[best.second]; ++i) {
        dp(u, i) = 1;
    }
    g[u]++;
    f[u].push_back(0);
    for (int i=1; i<=q+1; ++i) {
        dp(u, i) += tmp[i];
        tmp[i] = 0;
    }
    h[u] = q+1;

    for (auto& v : adj[u]) {
        if (v == p) continue;
        if (v == best.second) continue;
        for (int i=1; i<=g[v]; ++i) {
            ans[i*2] = max(ans[i*2], dp(v, i)+dp(u, i)-1+(lon[u]>= i));
        }
    }

    for (int i=1; i<=q+1; ++i) {
        int ic = dp(u, i) + (lon[u]>= i);
        int ipc = dp(u, i+1) + (lon[u]>= i+1);
        ans[i*2] = max(ans[i*2], ic);
        ans[i*2+1] = max(ans[i*2+1], ipc + (ic > ipc));
        //cerr << " : i = " << i << " :: " << ic << endl;
    }

    ////cerr << " : " << u << " " << g[u]+lon[u]<< " " << g[u] << endl;
    b2 = max(b2, g[u]+lon[u]);
    /*
    ans[g[u]+lon[u]]= max(ans[g[u]+lon[u]], 2);
    ans[g[u]+lon[u]-1]=max(ans[g[u]+lon[u]-1], 2);
    */
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> n;
    for (int i=0; i<=n; ++i) {
        h[i] = g[i] = -1;
    }
    for (int i=1; i<=n-1; ++i) {
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
        ans[i] = 1;
    }
    prep(1, -1, 1);
    prep2(1, -1, 0);
    ans[n] = 1;
    dfs(1, -1, 1);
    for (int i=1; i<=b2; ++i) {
        ans[i] = max(ans[i], 2);
    }
    for (int i=1; i<=n; ++i) {
        cout << ans[i] << " ";
    }
    cout << "\n";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;

const int N = 500500;
vector<int> f[N];
int tmp[N];
int g[N];
int h[N]; // largest length which is greater than j
int ans[N];
int hh[N]; // height of subtree
int lon[N]; // longest path through parent
vector<int> adj[N];
int zero = 0;
int n;

int& dp(const int& i, const int& j) {
    zero = 0;
    if (j>g[i]) return zero;
    return f[i][g[i]-j];
}

struct max2 {
    int first, second;
    max2() : first(-1), second(-1) {}
    void insert(int x) {
        if (x > first) {
            swap(first, second); first = x;
        } else if (x > second) {
            second = x;
        }
    }
    int other(int x) {
        return (x == first ? second : first);
    }
};

void prep(int u, int p, int hei) {
    ////cerr << " HH " << u << " " << hei << endl;
    hh[u] = hei;
    max2 m2;
    for (auto& v : adj[u]) {
        if (v == p) continue;
        prep(v, u, hei+1);
        ////cerr << "     INSERT " << v << " " << hh[v] << endl;
        m2.insert(hh[v]);
        hh[u] = max(hh[u], hh[v]);
    }
    for (auto& v : adj[u]) {
        if (v == p) continue;
        ////cerr << " UP " << v << " : " << m2.other(hh[v])-hei+1 << " :: " << m2.other(hh[v]) << " -- " << m2.first << " " << m2.second << endl;
        lon[v] = max(hei-1, m2.other(hh[v])-hei+1);
    }
}

void prep2(int u, int p, int b) {
    lon[u] = max(lon[u], b);
    for (auto& v : adj[u]) {
        if (v == p) continue;
        prep2(v, u, lon[u]+1);
    }
}

void dfs(int u, int p, int hei) {
    pii best(0, 0);
    for (auto& v : adj[u]) {
        if (v == p) continue;
        dfs(v, u, hei+1);
        best = max(best, pii(g[v], v));
    }

    ans[1] = max(ans[1], (int) adj[u].size()+1);

    int q = -1;
    for (auto& v : adj[u]) {
        if (v == p) continue;
        if (v == best.second) continue;
        for (int i=0; i<=g[v]; ++i) {
            tmp[i+1]++;
        }
        q = max(g[v], q);
    }

    //cerr << " ::::: " << u << endl;

    ans[best.first+q+2] = max(ans[best.first+q+2], 2);
    ans[best.first+q+1] = max(ans[best.first+q+1], 2);

    for (int i=1; i<=min(q+1, g[best.second]); ++i) {
        ans[i*2] = max(ans[i*2], tmp[i]+dp(best.second, i)+(lon[u]>= i));
    }

    f[u] = move(f[best.second]);
    g[u] = g[best.second];

    for (int i=0; i<=h[best.second]; ++i) {
        dp(u, i) = 1;
    }
    g[u]++;
    f[u].push_back(0);
    for (int i=1; i<=q+1; ++i) {
        dp(u, i) += tmp[i];
        tmp[i] = 0;
    }
    h[u] = q+1;

    for (auto& v : adj[u]) {
        if (v == p) continue;
        if (v == best.second) continue;
        for (int i=1; i<=g[v]; ++i) {
            ans[i*2] = max(ans[i*2], dp(v, i)+dp(u, i)-1+(lon[u]>= i));
        }
    }

    for (int i=1; i<=q+1; ++i) {
        int ic = dp(u, i) + (lon[u]>= i);
        int ipc = dp(u, i+1) + (lon[u]>= i+1);
        ans[i*2] = max(ans[i*2], ic);
        ans[i*2+1] = max(ans[i*2+1], ipc + (ic > ipc));
        //cerr << " : i = " << i << " :: " << ic << endl;
    }

    ////cerr << " : " << u << " " << g[u]+lon[u]<< " " << g[u] << endl;
    ans[g[u]+lon[u]]= max(ans[g[u]+lon[u]], 2);
    ans[g[u]+lon[u]-1]=max(ans[g[u]+lon[u]-1], 2);
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> n;
    for (int i=0; i<=n; ++i) {
        h[i] = g[i] = -1;
    }
    for (int i=1; i<=n-1; ++i) {
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
        ans[i] = 1;
    }
    prep(1, -1, 1);
    prep2(1, -1, 0);
    ans[n] = 1;
    dfs(1, -1, 1);
    for (int i=1; i<=n; ++i) {
        cout << ans[i] << " ";
    }
    cout << "\n";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;

const int N = 500500;
vector<int> f[N];
int tmp[N];
int g[N];
int h[N]; // largest length which is greater than j
int ans[N];
int hh[N]; // height of subtree
int lon[N]; // longest path through parent
vector<int> adj[N];
int zero = 0;
int b2 = 0;
int n;

inline int& dp(const int& i, const int& j) {
    zero = 0;
    if (j>g[i]) return zero;
    return f[i][g[i]-j];
}

struct max2 {
    int first, second;
    max2() : first(-1), second(-1) {}
    void insert(int x) {
        if (x > first) {
            swap(first, second); first = x;
        } else if (x > second) {
            second = x;
        }
    }
    int other(int x) {
        return (x == first ? second : first);
    }
};

void prep(int u, int p, int hei) {
    hh[u] = hei;
    max2 m2;
    for (auto& v : adj[u]) {
        if (v == p) continue;
        prep(v, u, hei+1);
        m2.insert(hh[v]);
        hh[u] = max(hh[u], hh[v]);
    }
    for (auto& v : adj[u]) {
        if (v == p) continue;
        lon[v] = max(hei-1, m2.other(hh[v])-hei+1);
    }
}

void prep2(int u, int p, int b) {
    lon[u] = max(lon[u], b);
    for (auto& v : adj[u]) {
        if (v == p) continue;
        prep2(v, u, lon[u]+1);
    }
}

void dfs(int u, int p, int hei) {
    pii best(0, 0);
    for (auto& v : adj[u]) {
        if (v == p) continue;
        dfs(v, u, hei+1);
        best = max(best, pii(g[v], v));
    }

    ans[1] = max(ans[1], (int) adj[u].size()+1);

    int q = -1;
    for (auto& v : adj[u]) {
        if (v == p) continue;
        if (v == best.second) continue;
        for (int i=0; i<=g[v]; ++i) {
            tmp[i+1]++;
        }
        q = max(g[v], q);
    }

    b2 = max((int) best.first+q+2, b2);

    for (int i=1; i<=min(q+1, g[best.second]); ++i) {
        ans[i*2] = max(ans[i*2], tmp[i]+dp(best.second, i)+(lon[u]>= i));
    }

    f[u] = move(f[best.second]);
    g[u] = g[best.second];

    for (int i=0; i<=h[best.second]; ++i) {
        dp(u, i) = 1;
    }
    g[u]++;
    f[u].push_back(0);
    for (int i=1; i<=q+1; ++i) {
        dp(u, i) += tmp[i];
        tmp[i] = 0;
    }
    h[u] = q+1;

    for (auto& v : adj[u]) {
        if (v == p) continue;
        if (v == best.second) continue;
        for (int i=1; i<=g[v]; ++i) {
            ans[i*2] = max(ans[i*2], dp(v, i)+dp(u, i)-1+(lon[u]>= i));
        }
    }

    for (int i=1; i<=q+1; ++i) {
        int ic = dp(u, i) + (lon[u]>= i);
        int ipc = dp(u, i+1) + (lon[u]>= i+1);
        ans[i*2] = max(ans[i*2], ic);
        ans[i*2+1] = max(ans[i*2+1], ipc + (ic > ipc));
    }

    b2 = max(b2, g[u]+lon[u]);
}

inline char get() {
    static char buf[100000], *S=buf, *T=buf;
    if (S==T) {
        T = (S=buf)+fread(buf, 1, 100000, stdin);
        if (S==T) return EOF;
    }
    return *S++;
}

void read(int& x) {
    static char c; x=0;
    for(c=get(); c<'0' || c>'9'; c=get());
    for(; c>='0'&&c<='9'; c=get()) x=x*10+c-'0';
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    read(n);
    for (int i=0; i<=n; ++i) {
        h[i] = g[i] = -1;
    }
    for (int i=1; i<=n-1; ++i) {
        int u, v;
        read(u); read(v);
        adj[u].push_back(v);
        adj[v].push_back(u);
        ans[i] = 1;
    }
    prep(1, -1, 1);
    prep2(1, -1, 0);
    ans[n] = 1;
    dfs(1, -1, 1);
    for (int i=1; i<=b2; ++i) {
        ans[i] = max(ans[i], 2);
    }
    for (int i=1; i<=n; ++i) {
        cout << ans[i] << " ";
    }
    cout << "\n";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;

const int N = 500500;
vector<int> f[N];
int tmp[N];
int g[N];
int h[N]; // largest length which is greater than j
int ans[N];
int hh[N]; // height of subtree
int lon[N]; // longest path through parent
vector<int> adj[N];
int zero = 0;
int n;

int& dp(const int& i, const int& j) {
    zero = 0;
    if (j>g[i]) return zero;
    return f[i][g[i]-j];
}

struct max2 {
    int first, second;
    max2() : first(-1), second(-1) {}
    void insert(int x) {
        if (x > first) {
            swap(first, second); first = x;
        } else if (x > second) {
            second = x;
        }
    }
    int other(int x) {
        return (x == first ? second : first);
    }
};

void prep(int u, int p, int hei) {
    //cerr << " HH " << u << " " << hei << endl;
    hh[u] = hei;
    max2 m2;
    for (auto& v : adj[u]) {
        if (v == p) continue;
        prep(v, u, hei+1);
        //cerr << "     INSERT " << v << " " << hh[v] << endl;
        m2.insert(hh[v]);
        hh[u] = max(hh[u], hh[v]);
    }
    for (auto& v : adj[u]) {
        if (v == p) continue;
        //cerr << " UP " << v << " : " << m2.other(hh[v])-hei+1 << " :: " << m2.other(hh[v]) << " -- " << m2.first << " " << m2.second << endl;
        lon[v] = max(hei-1, m2.other(hh[v])-hei+1);
    }
}

void prep2(int u, int p, int b) {
    lon[u] = max(lon[u], b);
    for (auto& v : adj[u]) {
        if (v == p) continue;
        prep2(v, u, lon[u]+1);
    }
}

void dfs(int u, int p, int hei) {
    pii best(0, 0);
    for (auto& v : adj[u]) {
        if (v == p) continue;
        dfs(v, u, hei+1);
        best = max(best, pii(g[v], v));
    }

    ans[1] = max(ans[1], (int) adj[u].size()+1);

    int q = -1;
    for (auto& v : adj[u]) {
        if (v == p) continue;
        if (v == best.second) continue;
        for (int i=0; i<=g[v]; ++i) {
            tmp[i+1]++;
        }
        q = max(g[v], q);
    }

    ans[best.first+q+2] = max(ans[best.first+q+2], 2);
    ans[best.first+q+1] = max(ans[best.first+q+1], 2);

    for (int i=1; i<=min(q+1, g[best.second]); ++i) {
        ans[i*2] = max(ans[i*2], tmp[i]+dp(best.second, i)+(lon[u]>= i));
    }

    f[u] = move(f[best.second]);
    g[u] = g[best.second];

    for (int i=0; i<=h[best.second]; ++i) {
        dp(u, i) = 1;
    }
    g[u]++;
    f[u].push_back(0);
    for (int i=1; i<=q+1; ++i) {
        dp(u, i) += tmp[i];
        tmp[i] = 0;
    }
    h[u] = q+1;

    for (auto& v : adj[u]) {
        if (v == p) continue;
        if (v == best.second) continue;
        for (int i=1; i<=g[v]; ++i) {
            ans[i*2] = max(ans[i*2], dp(v, i)+dp(u, i)-1+(lon[u]>= i));
        }
    }

    for (int i=1; i<=q; ++i) {
        int ic = dp(u, i) + (lon[u]>= i);
        int ipc = dp(u, i+1) + (lon[u]>= i+1);
        ans[i*2] = max(ans[i*2], ic);
        ans[i*2+1] = max(ans[i*2+1], ipc + (ic > ipc));
    }

    //cerr << " : " << u << " " << g[u]+lon[u]<< " " << g[u] << endl;
    ans[g[u]+lon[u]]= max(ans[g[u]+lon[u]], 2);
    ans[g[u]+lon[u]-1]=max(ans[g[u]+lon[u]-1], 2);
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> n;
    for (int i=0; i<=n; ++i) {
        h[i] = g[i] = -1;
    }
    for (int i=1; i<=n-1; ++i) {
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
        ans[i] = 1;
    }
    prep(1, -1, 1);
    prep2(1, -1, 0);
    ans[n] = 1;
    dfs(1, -1, 1);
    for (int i=1; i<=n; ++i) {
        cout << ans[i] << " ";
    }
    cout << "\n";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;

const int N = 500500;
vector<int> f[N];
int tmp[N];
int g[N];
int h[N]; // largest length which is greater than j
int ans[N];
int hh[N]; // height of subtree
int lon[N]; // longest path through parent
vector<int> adj[N];
int zero = 0;
int b2 = 0;
int n;

int& dp(const int& i, const int& j) {
    zero = 0;
    if (j>g[i]) return zero;
    return f[i][g[i]-j];
}

struct max2 {
    int first, second;
    max2() : first(-1), second(-1) {}
    void insert(int x) {
        if (x > first) {
            swap(first, second); first = x;
        } else if (x > second) {
            second = x;
        }
    }
    int other(int x) {
        return (x == first ? second : first);
    }
};

void prep(int u, int p, int hei) {
    ////cerr << " HH " << u << " " << hei << endl;
    hh[u] = hei;
    max2 m2;
    for (auto& v : adj[u]) {
        if (v == p) continue;
        prep(v, u, hei+1);
        ////cerr << "     INSERT " << v << " " << hh[v] << endl;
        m2.insert(hh[v]);
        hh[u] = max(hh[u], hh[v]);
    }
    for (auto& v : adj[u]) {
        if (v == p) continue;
        ////cerr << " UP " << v << " : " << m2.other(hh[v])-hei+1 << " :: " << m2.other(hh[v]) << " -- " << m2.first << " " << m2.second << endl;
        lon[v] = max(hei-1, m2.other(hh[v])-hei+1);
    }
}

void prep2(int u, int p, int b) {
    lon[u] = max(lon[u], b);
    for (auto& v : adj[u]) {
        if (v == p) continue;
        prep2(v, u, lon[u]+1);
    }
}

void dfs(int u, int p, int hei) {
    pii best(0, 0);
    for (auto& v : adj[u]) {
        if (v == p) continue;
        dfs(v, u, hei+1);
        best = max(best, pii(g[v], v));
    }

    ans[1] = max(ans[1], (int) adj[u].size()+1);

    int q = -1;
    for (auto& v : adj[u]) {
        if (v == p) continue;
        if (v == best.second) continue;
        for (int i=0; i<=g[v]; ++i) {
            tmp[i+1]++;
        }
        q = max(g[v], q);
    }

    //cerr << " ::::: " << u << endl;

    b2 = max((int) best.first+q+2, b2);
    /*
    ans[best.first+q+2] = max(ans[best.first+q+2], 2);
    ans[best.first+q+1] = max(ans[best.first+q+1], 2);
    */

    for (int i=1; i<=min(q+1, g[best.second]); ++i) {
        ans[i*2] = max(ans[i*2], tmp[i]+dp(best.second, i)+(lon[u]>= i));
    }

    f[u] = move(f[best.second]);
    g[u] = g[best.second];

    for (int i=0; i<=h[best.second]; ++i) {
        dp(u, i) = 1;
    }
    g[u]++;
    f[u].push_back(0);
    for (int i=1; i<=q+1; ++i) {
        dp(u, i) += tmp[i];
        tmp[i] = 0;
    }
    h[u] = q+1;

    for (auto& v : adj[u]) {
        if (v == p) continue;
        if (v == best.second) continue;
        for (int i=1; i<=g[v]; ++i) {
            ans[i*2] = max(ans[i*2], dp(v, i)+dp(u, i)-1+(lon[u]>= i));
        }
    }

    for (int i=1; i<=q+1; ++i) {
        int ic = dp(u, i) + (lon[u]>= i);
        int ipc = dp(u, i+1) + (lon[u]>= i+1);
        ans[i*2] = max(ans[i*2], ic);
        ans[i*2+1] = max(ans[i*2+1], ipc + (ic > ipc));
        //cerr << " : i = " << i << " :: " << ic << endl;
    }

    ////cerr << " : " << u << " " << g[u]+lon[u]<< " " << g[u] << endl;
    b2 = max(b2, g[u]+lon[u]);
    /*
    ans[g[u]+lon[u]]= max(ans[g[u]+lon[u]], 2);
    ans[g[u]+lon[u]-1]=max(ans[g[u]+lon[u]-1], 2);
    */
}

inline char get() {
    static char buf[100000], *S=buf, *T=buf;
    if (S==T) {
        T = (S=buf)+fread(buf, 1, 100000, stdin);
        if (S==T) return EOF;
    }
    return *S++;
}

void read(int& x) {
    static char c; x=0;
    for(c=get(); c<'0' || c>'9'; c=get());
    for(; c>='0'&&c<='9'; c=get()) x=x*10+c-'0';
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    read(n);
    for (int i=0; i<=n; ++i) {
        h[i] = g[i] = -1;
    }
    for (int i=1; i<=n-1; ++i) {
        int u, v;
        read(u); read(v);
        adj[u].push_back(v);
        adj[v].push_back(u);
        ans[i] = 1;
    }
    prep(1, -1, 1);
    prep2(1, -1, 0);
    ans[n] = 1;
    dfs(1, -1, 1);
    for (int i=1; i<=b2; ++i) {
        ans[i] = max(ans[i], 2);
    }
    for (int i=1; i<=n; ++i) {
        cout << ans[i] << " ";
    }
    cout << "\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define F2(i,a,b) for(int i=a;i<(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define Debug debug("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define MN 500005
#define MM 1000005
#define ll long long
#define mod 998244353
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
typedef pair<int,int> pii;
#define pb push_back
#define mkp make_pair
#define fi first
#define se second
inline void ckmx(int &x,int y){x=max(x,y);}
int n;
vector<int>G[MN];
int faz[MN],len[MN],gl[MN];
void DFS0(int u,int fz){
	faz[u]=fz;
	for(auto v:G[u])if(v!=fz)DFS0(v,u),len[u]=max(len[u],len[v]+1);
}
void DFS1(int u,int fz){
	static int pre[MN],suf[MN];
	int tp=0;
	for(auto v:G[u])if(v!=fz)pre[++tp]=len[v],suf[tp]=len[v];
	pre[0]=suf[tp+1]=gl[u];
	F(i,1,tp)pre[i]=max(pre[i],pre[i-1]);
	dF(i,tp,1)suf[i]=max(suf[i],suf[i+1]);
	tp=0;
	for(auto v:G[u])if(v!=fz)++tp,gl[v]=max(pre[tp-1],suf[tp+1])+1;
	for(auto v:G[u])if(v!=fz)DFS1(v,u);
}
vector<int>Vec[MN];
vector<pii>V2[MN],tmp;
inline void PB(int xx,int yy,int aa,int bb){
	if(xx==aa)--yy;
	if(xx==bb)--yy;
	if(yy)tmp.pb({xx,yy});
}
int Ans[MN];
int main(){int x,y;
	scanf("%d",&n);
	F(i,2,n)scanf("%d%d",&x,&y),G[x].pb(y),G[y].pb(x);
	if(n==2)return puts("2 1"),0;
	if(n==3)return puts("3 2 1"),0;
	DFS0(1,0);
//	F(i,1,n)printf("%d,",len[i]);puts("");
	gl[1]=-1,DFS1(1,0);
//	F(i,1,n)printf("%d,",gl[i]);puts("");
	F(i,1,n){
		for(auto v:G[i])if(v!=faz[i])Vec[i].pb(len[v]+1);
		if(i>1)Vec[i].pb(gl[i]+1);
		sort(Vec[i].begin(),Vec[i].end(),greater<int>());
		int lst=0,cnt=0;
		for(auto x:Vec[i])if(x!=lst){if(cnt)V2[i].pb({lst,cnt});lst=x,cnt=1;}else++cnt;
		if(cnt)V2[i].pb({lst,cnt});
//		for(auto x:V2[i])printf("(%d,%d),",x.fi,x.se);puts("");
	}
	F(i,1,n){
		int sz=V2[i].size(),sum=0;
		F(j,0,sz-1){
			sum+=V2[i][j].se;
			ckmx(Ans[V2[i][j].fi*2],sum);
			ckmx(Ans[V2[i][j].fi*2-1],sum);
			if(j+1<sz)ckmx(Ans[V2[i][j+1].fi*2+1],sum+1);
		}
		ckmx(Ans[1],sum+1);
	}
	F(u,2,n){
		int p=faz[u];
		tmp.clear();
		int sz1=V2[u].size(),sz2=V2[p].size();
		int i=0,j=0;
		int AA=len[u]+1,BB=gl[u]+1;
		while(i<sz1&&j<sz2){
			if(V2[u][i].fi==V2[p][j].fi){
				PB(V2[u][i].fi,V2[u][i].se+V2[p][j].se,AA,BB);
				++i,++j;
			}else if(V2[u][i].fi>V2[p][j].fi)
				PB(V2[u][i].fi,V2[u][i].se,AA,BB),
				++i;
			else
				PB(V2[p][j].fi,V2[p][j].se,AA,BB),
				++j;
		}
		while(i<sz1)PB(V2[u][i].fi,V2[u][i].se,AA,BB),++i;
		while(j<sz2)PB(V2[p][j].fi,V2[p][j].se,AA,BB),++j;
//		printf("%d--%d\n   ",u,p);
//		for(auto x:tmp)printf("(%d,%d),",x.fi,x.se);puts("");
		int sz=tmp.size(),sum=0;
		F(j,0,sz-1){
			sum+=tmp[j].se;
			ckmx(Ans[tmp[j].fi*2],sum);
		}
	}
	ckmx(Ans[n],1),ckmx(Ans[n-1],1);
	dF(i,n-2,1)ckmx(Ans[i],Ans[i+2]);
	F(i,1,n)printf("%d ",Ans[i]);puts("");
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

const int maxn=500010;

vector<int> e[maxn];
int pidx[maxn];
int sz[maxn];
vector<int> sa[maxn];
int pr[maxn];
void dfsxx(int x,int p,int z){
	pidx[x]=z;
	for(int i=0;i<e[x].size();i++){
		if(e[x][i]==p){
			swap(e[x][i],e[x].back());
			e[x].pop_back();
			i--;
		}
		else{
			dfsxx(e[x][i],x,i);
		}
	}
}

void dfsyy(int x){
	sz[x]=0;
	for(int it:e[x]){
		dfsyy(it);
		sz[x]=max(1+sz[it],sz[x]);
		sa[x].emplace_back(1+sz[it]);
	}
}

void dfszz(int x,int y){
	pr[x]=y;
	multiset<int> m;
	m.insert(y);
	for(int it:sa[x])
		m.insert(it);
	for(int i=0;i<e[x].size();i++){
		m.erase(m.find(sa[x][i]));
		dfszz(e[x][i],1+*prev(m.end()));
		m.insert(sa[x][i]);
	}
}
int ans[maxn];
int A[maxn];
void update(int x,int y){
	ans[x]=max(ans[x],y);
}
void Update(int x,int y){
	A[x]=max(A[x],y);
}

void dfs(int x){
	vector<int> v=sa[x];
	if(x!=1)
		v.emplace_back(pr[x]);
	sort(v.begin(),v.end());
	update(1,v.size()+1);
	for(int i=v.size()-1;i>=0;i--){
		if(i>0&&v[i-1]+1!=v[i])
			update(2*v[i-1]+1,v.size()-(i-1));
		update(2*v[i]-1,v.size()-i);
		update(2*v[i],v.size()-i);
	}
	for(int it:e[x])
		dfs(it);
	for(int it:e[x]){
		sort(sa[it].begin(),sa[it].end());
		if(sa[it].size()){
			for(int i=sa[it].size()-1;i>=0;i--){
				int z=lower_bound(v.begin(),v.end(),sa[it][i])-v.begin();
				Update(sa[it][i]*2,(int) sa[it].size()-i+(int) v.size()-z-1);

			}
		}
	}
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=1,u,v;i<n;i++){
		cin>>u>>v;
		e[u].emplace_back(v);
		e[v].emplace_back(u);
	}
	dfsxx(1,0,-1);dfsyy(1);dfszz(1,0);
	for(int i=1;i<=n;i++)
		ans[i]=1;
	dfs(1);
	for(int i=n-1;i>=1;i--)
		ans[i]=max(ans[i],ans[i+1]);
	for(int i=(n-1)/2*2;i>=2;i-=2)
		ans[i]=max(ans[i],max(ans[i+2],A[i]));
	for(int i=1;i<=n;i++)
		cout<<ans[i]<<' ';
	cout<<endl;
}


#include<bits/stdc++.h>
using namespace std;

const int maxn=500010;

vector<int> e[maxn];
int pidx[maxn];
int sz[maxn];
vector<int> sa[maxn];
int pr[maxn];
void dfsxx(int x,int p,int z){
	pidx[x]=z;
	for(int i=0;i<e[x].size();i++){
		if(e[x][i]==p){
			swap(e[x][i],e[x].back());
			e[x].pop_back();
			i--;
		}
		else{
			dfsxx(e[x][i],x,i);
		}
	}
}

void dfsyy(int x){
	sz[x]=0;
	for(int it:e[x]){
		dfsyy(it);
		sz[x]=max(1+sz[it],sz[x]);
		sa[x].emplace_back(1+sz[it]);
	}
}

void dfszz(int x,int y){
	pr[x]=y;
	multiset<int> m;
	m.insert(y);
	for(int it:sa[x])
		m.insert(it);
	for(int i=0;i<e[x].size();i++){
		m.erase(m.find(sa[x][i]));
		dfszz(e[x][i],1+*prev(m.end()));
		m.insert(sa[x][i]);
	}
}
int ans[maxn];
int A[maxn];
void update(int x,int y){
	ans[x]=max(ans[x],y);
}
void Update(int x,int y){
	A[x]=max(A[x],y);
}

void dfs(int x){
	vector<int> v=sa[x];
	if(x!=1)
		v.emplace_back(pr[x]);
	sort(v.begin(),v.end());
	update(1,v.size()+1);
	for(int i=v.size()-1;i>=0;i--){
		if(i>0&&v[i-1]!=v[i])
			update(2*v[i-1]+1,v.size()-(i-1));
		update(2*v[i]-1,v.size()-i);
		update(2*v[i],v.size()-i);
	}
	for(int it:e[x])
		dfs(it);
	for(int it:e[x]){
		sort(sa[it].begin(),sa[it].end());
		if(sa[it].size()){
			for(int i=sa[it].size()-1;i>=0;i--){
				int z=lower_bound(v.begin(),v.end(),sa[it][i])-v.begin();
				Update(sa[it][i]*2,(int) sa[it].size()-i+(int) v.size()-z-1);
			}
			for(int i=v.size()-1;i>=0;i--){
				int z=lower_bound(sa[it].begin(),sa[it].end(),v[i])-sa[it].begin();
				Update(v[i]*2,(int) sa[it].size()-i+(int) v.size()-z-1);

			}
		}
	}
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=1,u,v;i<n;i++){
		cin>>u>>v;
		e[u].emplace_back(v);
		e[v].emplace_back(u);
	}
	dfsxx(1,0,-1);dfsyy(1);dfszz(1,0);
	for(int i=1;i<=n;i++)
		ans[i]=1;
	dfs(1);
	for(int i=n-1;i>=1;i--)
		ans[i]=max(ans[i],ans[i+1]);
	for(int i=(n-1)/2*2;i>=2;i-=2)
		ans[i]=max(ans[i],max(ans[i+2],A[i]));
	for(int i=1;i<=n;i++)
		cout<<ans[i]<<' ';
	cout<<endl;
}


#include<bits/stdc++.h>
using namespace std;

const int maxn=500010;

vector<int> e[maxn];
int pidx[maxn];
int sz[maxn];
vector<int> sa[maxn];
int pr[maxn];
void dfsxx(int x,int p,int z){
	pidx[x]=z;
	for(int i=0;i<e[x].size();i++){
		if(e[x][i]==p){
			swap(e[x][i],e[x].back());
			e[x].pop_back();
			i--;
		}
		else{
			dfsxx(e[x][i],x,i);
		}
	}
}

void dfsyy(int x){
	sz[x]=0;
	for(int it:e[x]){
		dfsyy(it);
		sz[x]=max(1+sz[it],sz[x]);
		sa[x].emplace_back(1+sz[it]);
	}
}

void dfszz(int x,int y){
	pr[x]=y;
	multiset<int> m;
	m.insert(y);
	for(int it:sa[x])
		m.insert(it);
	for(int i=0;i<e[x].size();i++){
		m.erase(m.find(sa[x][i]));
		dfszz(e[x][i],1+*prev(m.end()));
		m.insert(sa[x][i]);
	}
}
int ans[maxn];

void update(int x,int y){
	ans[x]=max(ans[x],y);
}

void dfs(int x){
	vector<int> v=sa[x];
	if(x!=1)
		v.emplace_back(pr[x]);
	sort(v.begin(),v.end());
	update(1,v.size()+1);
	for(int i=v.size()-1;i>=0;i--){
		if(i>0&&v[i-1]+1==v[i])
			update(2*v[i]-1,v.size()-(i-1));
		update(2*v[i]-1,v.size()-i);
		update(2*v[i],v.size()-i);
	}
	for(int it:e[x])
		dfs(it);
	sort(v.begin(),v.end());
	for(int it:e[x]){
		sort(sa[it].begin(),sa[it].end());
		if(sa[it].size()){
			for(int i=sa[it].size()-1;i>=0;i--){
				int z=lower_bound(v.begin(),v.end(),sa[it][i])-v.begin();
				update(sa[it][i]*2,(int) sa[it].size()-i+(int) v.size()-z-1);

			}
		}
	}
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=1,u,v;i<n;i++){
		cin>>u>>v;
		e[u].emplace_back(v);
		e[v].emplace_back(u);
	}
	dfsxx(1,0,-1);dfsyy(1);dfszz(1,0);
	for(int i=1;i<=n;i++)
		ans[i]=1;
	dfs(1);
	for(int i=n-1;i>=1;i--)
		ans[i]=max(ans[i],ans[i+1]);
	for(int i=1;i<=n;i++)
		cout<<ans[i]<<' ';
	cout<<endl;
}


#include<bits/stdc++.h>
using namespace std;

const int maxn=500010;

vector<int> e[maxn];
int pidx[maxn];
int sz[maxn];
vector<int> sa[maxn];
int pr[maxn];
void dfsxx(int x,int p,int z){
	pidx[x]=z;
	for(int i=0;i<e[x].size();i++){
		if(e[x][i]==p){
			swap(e[x][i],e[x].back());
			e[x].pop_back();
			i--;
		}
		else{
			dfsxx(e[x][i],x,i);
		}
	}
}

void dfsyy(int x){
	sz[x]=0;
	for(int it:e[x]){
		dfsyy(it);
		sz[x]=max(1+sz[it],sz[x]);
		sa[x].emplace_back(1+sz[it]);
	}
}

void dfszz(int x,int y){
	pr[x]=y;
	multiset<int> m;
	m.insert(y);
	for(int it:sa[x])
		m.insert(it);
	for(int i=0;i<e[x].size();i++){
		m.erase(m.find(sa[x][i]));
		dfszz(e[x][i],1+*prev(m.end()));
		m.insert(sa[x][i]);
	}
}
int ans[maxn];
int A[maxn];
void update(int x,int y){
	ans[x]=max(ans[x],y);
}
void Update(int x,int y){
	A[x]=max(A[x],y);
}

void dfs(int x){
	vector<int> v=sa[x];
	if(x!=1)
		v.emplace_back(pr[x]);
	sort(v.begin(),v.end());
	update(1,v.size()+1);
	for(int i=v.size()-1;i>=0;i--){
		if(i>0&&v[i-1]!=v[i])
			update(2*v[i-1]+1,v.size()-(i-1));
		update(2*v[i]-1,v.size()-i);
		update(2*v[i],v.size()-i);
	}
	for(int it:e[x])
		dfs(it);
	for(int it:e[x]){
		sort(sa[it].begin(),sa[it].end());
		if(sa[it].size()){
			for(int i=sa[it].size()-1;i>=0;i--){
				int z=lower_bound(v.begin(),v.end(),sa[it][i])-v.begin();
				Update(sa[it][i]*2,(int) sa[it].size()-i+(int) v.size()-z-1);

			}
		}
	}
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=1,u,v;i<n;i++){
		cin>>u>>v;
		e[u].emplace_back(v);
		e[v].emplace_back(u);
	}
	dfsxx(1,0,-1);dfsyy(1);dfszz(1,0);
	for(int i=1;i<=n;i++)
		ans[i]=1;
	dfs(1);
	for(int i=n-1;i>=1;i--)
		ans[i]=max(ans[i],ans[i+1]);
	for(int i=(n-1)/2*2;i>=2;i-=2)
		ans[i]=max(ans[i],max(ans[i+2],A[i]));
	for(int i=1;i<=n;i++)
		cout<<ans[i]<<' ';
	cout<<endl;
}


#include<bits/stdc++.h>
using namespace std;

const int maxn=500010;

vector<int> e[maxn];
int pidx[maxn];
int sz[maxn];
vector<int> sa[maxn];
int pr[maxn];
void dfsxx(int x,int p,int z){
	pidx[x]=z;
	for(int i=0;i<e[x].size();i++){
		if(e[x][i]==p){
			swap(e[x][i],e[x].back());
			e[x].pop_back();
			i--;
		}
		else{
			dfsxx(e[x][i],x,i);
		}
	}
}

void dfsyy(int x){
	sz[x]=0;
	for(int it:e[x]){
		dfsyy(it);
		sz[x]=max(1+sz[it],sz[x]);
		sa[x].emplace_back(1+sz[it]);
	}
}

void dfszz(int x,int y){
	pr[x]=y;
	multiset<int> m;
	m.insert(y);
	for(int it:sa[x])
		m.insert(it);
	for(int i=0;i<e[x].size();i++){
		m.erase(m.find(sa[x][i]));
		dfszz(e[x][i],1+*prev(m.end()));
		m.insert(sa[x][i]);
	}
}
int ans[maxn];
int A[maxn];
void update(int x,int y){
	ans[x]=max(ans[x],y);
}
void Update(int x,int y){
	A[x]=max(A[x],y);
}

void dfs(int x){
	vector<int> v=sa[x];
	if(x!=1)
		v.emplace_back(pr[x]);
	sort(v.begin(),v.end());
	update(1,v.size()+1);
	for(int i=v.size()-1;i>=0;i--){
		if(i>0&&v[i-1]+1==v[i])
			update(2*v[i]-1,v.size()-(i-1));
		update(2*v[i]-1,v.size()-i);
		update(2*v[i],v.size()-i);
	}
	for(int it:e[x])
		dfs(it);
	for(int it:e[x]){
		sort(sa[it].begin(),sa[it].end());
		if(sa[it].size()){
			for(int i=sa[it].size()-1;i>=0;i--){
				int z=lower_bound(v.begin(),v.end(),sa[it][i])-v.begin();
				Update(sa[it][i]*2,(int) sa[it].size()-i+(int) v.size()-z-1);

			}
		}
	}
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=1,u,v;i<n;i++){
		cin>>u>>v;
		e[u].emplace_back(v);
		e[v].emplace_back(u);
	}
	dfsxx(1,0,-1);dfsyy(1);dfszz(1,0);
	for(int i=1;i<=n;i++)
		ans[i]=1;
	dfs(1);
	for(int i=n-1;i>=1;i--)
		ans[i]=max(ans[i],ans[i+1]);
	for(int i=(n-1)/2*2;i>=2;i-=2)
		ans[i]=max(ans[i],max(ans[i+2],A[i]));
	for(int i=1;i<=n;i++)
		cout<<ans[i]<<' ';
	cout<<endl;
}


		if(i>0&&v[i-1]!=v[i])
			update(2*v[i-1]+1,v.size()-(i-1));
		update(2*v[i]-1,v.size()-i);
		update(2*v[i],v.size()-i);
	}
	for(int it:e[x])
		dfs(it);
	for(int it:e[x]){
		sort(sa[it].begin(),sa[it].end());
		if(sa[it].size()){
			for(int i=sa[it].size()-1;i>=0;i--){
				int z=lower_bound(v.begin(),v.end(),sa[it][i])-v.begin();
				Update(sa[it][i]*2,(int) sa[it].size()-i+(int) v.size()-z-1);

			}
		}
	}
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=1,u,v;i<n;i++){
		cin>>u>>v;
		e[u].emplace_back(v);
		e[v].emplace_back(u);
	}
	dfsxx(1,0,-1);dfsyy(1);dfszz(1,0);
	for(int i=1;i<=n;i++)
		ans[i]=1;
	dfs(1);
	for(int i=n-1;i>=1;i--)
		ans[i]=max(ans[i],ans[i+1]);
	for(int i=(n-1)/2*2;i>=2;i-=2)
		ans[i]=max(ans[i],max(ans[i+2],A[i]));
	for(int i=1;i<=n;i++)
		cout<<ans[i]<<' ';
	cout<<endl;
}


#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <utility>
#include <cassert>
#include <limits.h>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <iostream>
#include <iomanip>

using namespace std;

using vi = vector<int>;
using pii = pair<int, int>;
using vii = vector<pii>;
using ll = long long;

int solve();

int main(int argc, char* argv[])
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif //ONLINE_JUDGE
	::std::ios::sync_with_stdio(false);
	::std::cin.tie(0);
	::std::cout.tie(0);

	int t = 1;
	//cin >> t;

	while (t--) {
		solve();
	}
}

constexpr int N = 500005;
int n, u, v, h[N], g[N], parent[N], ans[N*2], val[N];
int mx = 0, ed = 0, child[N];
bool check[N];
pii f[N][2];
vi adj[N], eve[N];
void dfs(int u, int p)
{
	h[u] = h[p] + 1;
	parent[u] = p;
	f[u][0] = make_pair(0, u);
	f[u][1] = make_pair(-1, 0);
	for (int v : adj[u])
	{
		if (v != p) {
			dfs(v, u);
			auto temp = f[v][0];
			temp.first++;
			temp.second = v;
			for (int i = 0; i < 2; ++i) {
				if (temp > f[u][i]) {
					swap(temp, f[u][i]);
				}
			}
		}
	}
}

void dfs_v2(int u, int p)
{
	eve[0].push_back(u);
	if (p != 0) {
		g[u] = max(g[p], f[p][0].second == u ? f[p][1].first : f[p][0].first) + 1;
		eve[g[u]].push_back(u);
	}
	for (int v : adj[u])
	{
		if (v != p) {
			eve[f[v][0].first + 1].push_back(u);
			dfs_v2(v, u);
		}
	}
}

int solve()
{
	cin >> n;

	for (int i = 1; i < n; i++)
	{
		cin >> u >> v;

		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	dfs(1, 0);
	dfs_v2(1, 0);

	for (int i = n; i >= 0; i--)
	{
		int ev = i * 2, od = i * 2 + 1;
		ans[od] = mx;
		for (int  v : eve[i])
		{
			if (!check[v])
			{
				check[v] = true;
				ans[od] = ::std::max(ans[od], val[v] + 1);
			}
		}

		for (int  v : eve[i])
		{
			check[v] = false;
			mx = max(mx, ++val[v]);
			ed = std::max(ed, val[v] + child[v] - 2);
			if (v != 1)
			{
				const int pv = parent[v];
				child[pv] = max(child[pv], val[v]);
				ed = std::max(ed, val[pv] + child[pv] - 2);
			}
		}
		ans[ev] = max(mx, ed);
	}

	for (int i = 1; i <= n; i++)
	{
		cout << ::std::max(ans[i], 1) << " ";
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<vector<int>> g(n);
  for (int i = 0; i < n - 1; ++i) {
    int v, u;
    cin >> v >> u;
    --v; --u;
    g[v].push_back(u);
    g[u].push_back(v);
  }
  vector<int> pr(n, -1);
  vector<int> foo(n);
  vector<int> bar(n);
  vector<int> baz(n);
  function<void(int)> dfs_up = [&](int v) {
    for (int u : g[v]) {
      if (u != pr[v]) {
        pr[u] = v;
        dfs_up(u);
        bar[v] = max(bar[v], foo[u] + 1);
        if (foo[v] < bar[v]) {
          swap(foo[v], bar[v]);
        }
      }
    }
  };
  function<void(int)> dfs_down = [&](int v) {
    for (int u : g[v]) {
      if (u != pr[v]) {
        baz[u] = 1 + max(baz[v], foo[u] + 1 == foo[v] ? bar[v] : foo[v]);
        dfs_down(u);
      }
    }
  };
  dfs_up(0);
  dfs_down(0);
  vector<int> ans(n * 2 + 1, 1);
  vector<vector<int>> d(n);
  for (int v = 0; v < n; ++v) {
    vector<int> ds;
    for (int u : g[v]) {
      if (u == pr[v]) {
        ds.push_back(baz[v]);
      } else {
        ds.push_back(foo[u] + 1);
      }
    }
    sort(ds.begin(), ds.end(), greater<int>());
    for (int i = 1; i < (int) ds.size(); ++i) {
      ans[2 * ds[i]] = max(ans[2 * ds[i]], i + 1);
      ans[2 * min(ds[i] + 1, ds[i - 1]) - 1] = max(ans[2 * min(ds[i] + 1, ds[i - 1]) - 1], i + 1);
    }
    d[v] = ds;
  }
  vector<int> ord(n);
  for (int i = 0; i < n; ++i) {
    ord[i] = i;
  }
  sort(ord.begin(), ord.end(), [&](int v, int u) { return g[v].size() > g[u].size() || (g[v].size() == g[u].size() && v < u); });
  for (int v : ord) {
    vector<pair<int, int>> cut;
    for (int u : g[v]) {
      if (g[v].size() > g[u].size() || (g[v].size() == g[u].size() && v < u)) {
        for (int i = 1; i < (int) d[u].size(); ++i) {
          cut.emplace_back(d[u][i], i);
        }
      }
    }
    sort(cut.begin(), cut.end(), greater<pair<int, int>>());
    for (int i = 1; i < (int) cut.size(); ++i) {
      cut[i].second = max(cut[i].second, cut[i - 1].second);
    }
    int j = 0;
    for (int i = 1; i < (int) d[v].size(); ++i) {
      while (j < (int) cut.size() && cut[j].first >= d[v][i]) {
        if (i > 1) {
          ans[2 * cut[j].first] = max(ans[2 * cut[j].first], i - 1 + cut[j].second);
        }
        ++j;
      }
      if (j) {
        ans[2 * d[v][i]] = max(ans[2 * d[v][i]], i + cut[j - 1].second);
      }
    }
    while (j < (int) cut.size()) {
      if ((int) d[v].size() > 1) {
        ans[2 * cut[j].first] = max(ans[2 * cut[j].first], (int) d[v].size() - 1 + cut[j].second);
      }
      ++j;
    }
  }
  for (int i = n - 2; i; --i) {
    ans[i] = max(ans[i], ans[i + 2]);
  }
  for (int i = 0; i < n; ++i) {
    ans[1] = max(ans[1], (int) g[i].size() + 1);
  }
  for (int i = 1; i <= n; ++i) {
    if (i != 1) {
      cout << " ";
    }
    cout << ans[i];
  }
  cout << "\n";
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
class Obj{
public:
	int deep, already;
	Obj(int b, int c){
		deep = b;
		already = c;
	}
};

class Node{
public:
	Node *l, *r;
	ll maxi, lazy;
	int s, e;
	Node(int a, int b){
		s = a;
		e = b;
		maxi = 0;
		lazy = 0;
		l = NULL;
		r = NULL;
		if(s!=e){
			l = new Node(s,(s+e)/2);
			r = new Node((s+e)/2+1,e);
		}
	}
	void push(){
		if(lazy!=0 && s!=e){
			l->maxi += lazy;
			l->lazy += lazy;
			r->maxi += lazy;
			r->lazy += lazy;
		}
		lazy = 0LL;
	}
	void pull(){
		if(s!=e){
			maxi = max(l->maxi,r->maxi);
		}
	}
	void add(int st, int en, ll val){
		push();
		if(st <= s && e <= en){
			maxi += val;
			lazy += val;
			return;
		}
		if(st <= (s+e)/2){
			l->add(st,en,val);
		}
		if(en>(s+e)/2){
			r->add(st,en,val);
		}
		pull();
	}
	ll gmax(int st, int en){
		push();
		if(st <= s && e <= en){
			return maxi;
		}
		ll ret = 0LL;
		if(st<=(s+e)/2){
			ret = max(ret,l->gmax(st,en));
		}
		if(en>(s+e)/2){
			ret = max(ret,r->gmax(st,en));
		}
		return ret;
	}
};
int pre[500000];
int post[500000];
int h[500000];
int bel[500000];
vector<int> adj[500000];
int point = 0;
int diam = 0;
int ans[500001];
vector<Obj> reqs[500001];
void dfs(int now, int from, int cur){
	pre[now] = point++;
	bel[now] = 0;
	h[now] = cur;
	for(int i = 0; i<adj[now].size(); i++){
		int to = adj[now][i];
		if(to==from){
			continue;
		}
		dfs(to,now,cur+1);
		bel[now] = max(bel[now],1+bel[to]);
	}
	post[now] = point-1;
}
Node *t = NULL;
int n;
void addr(int l, int r, int x){
	if(l>0){
		t->add(0,l-1,x);
	}
	if(r<n-1){
		t->add(r+1,n-1,x);
	}
}
int maxr(int l, int r){
	int ret = 0;
	if(l>0){
		ret= max(ret,(int)(t->gmax(0,l-1)));
	}
	if(r<n-1){
		ret = max(ret,(int)(t->gmax(r+1,n-1)));
	}
	return ret;
}
void go(int now, int from){
	vector<int> b;

	for(int i = 0; i<adj[now].size(); i++){
		int to = adj[now][i];
		if(to==from){
			continue;
		}
		addr(pre[to],post[to],1);
		t->add(pre[to],post[to],-1);
		go(to,now);
		t->add(pre[to],post[to],1);
		addr(pre[to],post[to],-1);
		b.push_back(to);
	}
	vector<int> all;
	int zz = maxr(pre[now],post[now]);
	diam = max(diam,zz);
	all.push_back(zz);
	for(int i = 0; i<b.size(); i++){
		all.push_back(bel[b[i]]+1);
	}
	if(b.size()<=1){
		return;
	}
	sort(all.begin(),all.end());
	int p1 = 2;
	int p2 = 0;
	int rem = all.size();
	b.clear();
	while(true){
		while(rem>=2 && p2<=all.size()-2 && (p1+1)/2>all[p2]){
			p2++;
			rem--;
		}
		if(rem>=2 && p2<=all.size()-2 && (p1+1)/2<=all[p2]){
			int val = rem;
			if(p1%2==1 && p2>0 && all[p2-1]>=p1/2){
				val++;
			}
			else if(rem==2 && p1%2==1){
				break;
			}
			if(rem>2 && p1%2==0 && all[all.size()-2]>=p1/2 && zz>=p1/2){
				reqs[from].push_back(Obj(p1/2,val));
			}
			ans[p1] = max(ans[p1],val);
			p1++;
		}
		else{
			break;
		}
	}
	all.clear();
}
void go2(int now, int from){
	vector<int> b;

	for(int i = 0; i<adj[now].size(); i++){
		int to = adj[now][i];
		if(to==from){
			continue;
		}
		addr(pre[to],post[to],1);
		t->add(pre[to],post[to],-1);
		go2(to,now);
		t->add(pre[to],post[to],1);
		addr(pre[to],post[to],-1);
		b.push_back(to);
	}
	vector<int> all;
	int zz = maxr(pre[now],post[now]);
	diam = max(diam,zz);
	all.push_back(zz);
	for(int i = 0; i<b.size(); i++){
		all.push_back(bel[b[i]]+1);
	}
	b.clear();
	sort(all.begin(),all.end());
	for(int i = 0; i<reqs[now].size(); i++){
		int deep = reqs[now][i].deep;
		int already = reqs[now][i].already;
		int lo = 1;
		int hi = all.size();
		while(lo<hi){
			int mid = (lo+hi+1)/2;
			if(all[all.size()-mid]>=deep){
				lo = mid;
			}
			else{
				hi = mid-1;
			}
		}
		ans[deep*2] = max(ans[deep*2],lo+already-2);
	}
	all.clear();
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	t = new Node(0,n-1);
	for(int i = 1; i<n; i++){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	for(int i = 0; i<=n; i++){
		ans[i] = 1;
	}
	dfs(0,-1,0);
	for(int i = 0; i<n; i++){
		t->add(pre[i],pre[i],h[i]);
	}
	go(0,-1);
	go2(0,-1);
	for(int i = 1; i<=diam; i++){
		ans[i] = max(ans[i],2);
	}
	ans[1] = 0;
	ans[2] = 0;
	for(int i = 0; i<n; i++){
		ans[1] = max(ans[1],1+(int)adj[i].size());
		ans[2] = max(ans[2],(int)adj[i].size());
		for(int j = 0; j<adj[i].size(); j++){
			int to = adj[i][j];
			ans[2] = max(ans[2],(int)(adj[i].size()+adj[to].size()-2));
		}
	}
	for(int i = 1; i<=n; i++){
		cout << ans[i] << " ";
	}
	cout << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
class Obj{
public:
	int loc, deep, already;
	Obj(int a, int b, int c){
		loc = a;
		deep = b;
		already = c;
	}
};

class Node{
public:
	Node *l, *r;
	ll maxi, lazy;
	int s, e;
	Node(int a, int b){
		s = a;
		e = b;
		maxi = 0;
		lazy = 0;
		l = NULL;
		r = NULL;
		if(s!=e){
			l = new Node(s,(s+e)/2);
			r = new Node((s+e)/2+1,e);
		}
	}
	void push(){
		if(lazy!=0 && s!=e){
			l->maxi += lazy;
			l->lazy += lazy;
			r->maxi += lazy;
			r->lazy += lazy;
		}
		lazy = 0LL;
	}
	void pull(){
		if(s!=e){
			maxi = max(l->maxi,r->maxi);
		}
	}
	void add(int st, int en, ll val){
		push();
		if(st <= s && e <= en){
			maxi += val;
			lazy += val;
			return;
		}
		if(st <= (s+e)/2){
			l->add(st,en,val);
		}
		if(en>(s+e)/2){
			r->add(st,en,val);
		}
		pull();
	}
	ll gmax(int st, int en){
		push();
		if(st <= s && e <= en){
			return maxi;
		}
		ll ret = 0LL;
		if(st<=(s+e)/2){
			ret = max(ret,l->gmax(st,en));
		}
		if(en>(s+e)/2){
			ret = max(ret,r->gmax(st,en));
		}
		return ret;
	}
};
int pre[500000];
int post[500000];
int h[500000];
int bel[500000];
vector<int> adj[500000];
int point = 0;
int diam = 0;
int ans[500001];
vector<Obj> reqs[500001];
void dfs(int now, int from, int cur){
	pre[now] = point++;
	bel[now] = 0;
	h[now] = cur;
	for(int i = 0; i<adj[now].size(); i++){
		int to = adj[now][i];
		if(to==from){
			continue;
		}
		dfs(to,now,cur+1);
		bel[now] = max(bel[now],1+bel[to]);
	}
	post[now] = point-1;
}
Node *t = NULL;
int n;
void addr(int l, int r, int x){
	if(l>0){
		t->add(0,l-1,x);
	}
	if(r<n-1){
		t->add(r+1,n-1,x);
	}
}
int maxr(int l, int r){
	int ret = 0;
	if(l>0){
		ret= max(ret,(int)(t->gmax(0,l-1)));
	}
	if(r<n-1){
		ret = max(ret,(int)(t->gmax(r+1,n-1)));
	}
	return ret;
}
void go(int now, int from){
	vector<int> b;

	for(int i = 0; i<adj[now].size(); i++){
		int to = adj[now][i];
		if(to==from){
			continue;
		}
		addr(pre[to],post[to],1);
		t->add(pre[to],post[to],-1);
		go(to,now);
		t->add(pre[to],post[to],1);
		addr(pre[to],post[to],-1);
		b.push_back(to);
	}
	vector<int> all;
	int zz = maxr(pre[now],post[now]);
	diam = max(diam,zz);
	all.push_back(zz);
	for(int i = 0; i<b.size(); i++){
		all.push_back(bel[b[i]]+1);
	}
	if(b.size()<=1){
		return;
	}
	sort(all.begin(),all.end());
	int p1 = 2;
	int p2 = 0;
	int rem = all.size();
	while(true){
		while(rem>=2 && p2<=all.size()-2 && (p1+1)/2>all[p2]){
			p2++;
			rem--;
		}
		if(rem>=2 && p2<=all.size()-2 && (p1+1)/2<=all[p2]){
			int val = rem;
			if(p1%2==1 && p2>0 && all[p2-1]>=p1/2){
				val++;
			}
			if(p1%2==0 && all[all.size()-2]>=p1/2 && zz>=p1/2){
				reqs[from].push_back(Obj(from,p1/2,val));
			}
			ans[p1] = max(ans[p1],val);
			p1++;
		}
		else{
			break;
		}
	}
}
void go2(int now, int from){
	vector<int> b;

	for(int i = 0; i<adj[now].size(); i++){
		int to = adj[now][i];
		if(to==from){
			continue;
		}
		addr(pre[to],post[to],1);
		t->add(pre[to],post[to],-1);
		go2(to,now);
		t->add(pre[to],post[to],1);
		addr(pre[to],post[to],-1);
		b.push_back(to);
	}
	vector<int> all;
	int zz = maxr(pre[now],post[now]);
	diam = max(diam,zz);
	all.push_back(zz);
	for(int i = 0; i<b.size(); i++){
		all.push_back(bel[b[i]]+1);
	}
	sort(all.begin(),all.end());
	for(int i = 0; i<reqs[now].size(); i++){
		int deep = reqs[now][i].deep;
		int already = reqs[now][i].already;
		int lo = 1;
		int hi = all.size();
		while(lo<hi){
			int mid = (lo+hi+1)/2;
			if(all[all.size()-mid]>=deep){
				lo = mid;
			}
			else{
				hi = mid-1;
			}
		}
		ans[deep*2] = max(ans[deep*2],lo+already-2);
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	t = new Node(0,n-1);
	for(int i = 1; i<n; i++){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	for(int i = 0; i<=n; i++){
		ans[i] = 1;
	}
	dfs(0,-1,0);
	for(int i = 0; i<n; i++){
		t->add(pre[i],pre[i],h[i]);
	}
	go(0,-1);
	go2(0,-1);
	for(int i = 1; i<=diam; i++){
		ans[i] = max(ans[i],2);
	}
	ans[1] = 0;
	ans[2] = 0;
	for(int i = 0; i<n; i++){
		ans[1] = max(ans[1],1+(int)adj[i].size());
		ans[2] = max(ans[2],(int)adj[i].size());
		for(int j = 0; j<adj[i].size(); j++){
			int to = adj[i][j];
			ans[2] = max(ans[2],(int)(adj[i].size()+adj[to].size()-2));
		}
	}
	for(int i = 1; i<=n; i++){
		cout << ans[i] << " ";
	}
	cout << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
class Node{
public:
	Node *l, *r;
	ll maxi, lazy;
	int s, e;
	Node(int a, int b){
		s = a;
		e = b;
		maxi = 0;
		lazy = 0;
		l = NULL;
		r = NULL;
		if(s!=e){
			l = new Node(s,(s+e)/2);
			r = new Node((s+e)/2+1,e);
		}
	}
	void push(){
		if(lazy!=0 && s!=e){
			l->maxi += lazy;
			l->lazy += lazy;
			r->maxi += lazy;
			r->lazy += lazy;
		}
		lazy = 0LL;
	}
	void pull(){
		if(s!=e){
			maxi = max(l->maxi,r->maxi);
		}
	}
	void add(int st, int en, ll val){
		push();
		if(st <= s && e <= en){
			maxi += val;
			lazy += val;
			return;
		}
		if(st <= (s+e)/2){
			l->add(st,en,val);
		}
		if(en>(s+e)/2){
			r->add(st,en,val);
		}
		pull();
	}
	ll gmax(int st, int en){
		push();
		if(st <= s && e <= en){
			return maxi;
		}
		ll ret = 0LL;
		if(st<=(s+e)/2){
			ret = max(ret,l->gmax(st,en));
		}
		if(en>(s+e)/2){
			ret = max(ret,r->gmax(st,en));
		}
		return ret;
	}
};
int pre[500000];
int post[500000];
int h[500000];
int bel[500000];
vector<int> adj[500000];
int point = 0;
int diam = 0;
int ans[500001];
void dfs(int now, int from, int cur){
	pre[now] = point++;
	bel[now] = 0;
	h[now] = cur;
	for(int i = 0; i<adj[now].size(); i++){
		int to = adj[now][i];
		if(to==from){
			continue;
		}
		dfs(to,now,cur+1);
		bel[now] = max(bel[now],1+bel[to]);
	}
	post[now] = point-1;
}
Node *t = NULL;
int n;
void addr(int l, int r, int x){
	if(l>0){
		t->add(0,l-1,x);
	}
	if(r<n-1){
		t->add(r+1,n-1,x);
	}
}
int maxr(int l, int r){
	int ret = 0;
	if(l>0){
		ret= max(ret,(int)(t->gmax(0,l-1)));
	}
	if(r<n-1){
		ret = max(ret,(int)(t->gmax(r+1,n-1)));
	}
	return ret;
}
void go(int now, int from){
	vector<int> b;

	for(int i = 0; i<adj[now].size(); i++){
		int to = adj[now][i];
		if(to==from){
			continue;
		}
		addr(pre[to],post[to],1);
		t->add(pre[to],post[to],-1);
		go(to,now);
		t->add(pre[to],post[to],1);
		addr(pre[to],post[to],-1);
		b.push_back(to);
	}
	vector<int> all;
	int zz = maxr(pre[now],post[now]);
	diam = max(diam,zz);
	all.push_back(zz);
	for(int i = 0; i<b.size(); i++){
		all.push_back(bel[b[i]]+1);
	}
	if(b.size()<=1){
		return;
	}
	sort(all.begin(),all.end());
	int p1 = 1;
	int p2 = 0;
	int rem = all.size();
	while(true){
		while(rem>=2 && p2<=all.size()-2 && (p1+1)/2>all[p2]){
			p2++;
			rem--;
		}
		if(rem>=2 && p2<=all.size()-2 && (p1+1)/2<=all[p2]){
			int val = rem;
			if(p1%2==1 && p2>0 && all[p2-1]>=p1/2){
				val++;
			}
			ans[p1] = max(ans[p1],val);
			p1++;
		}
		else{
			break;
		}
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	t = new Node(0,n-1);
	for(int i = 1; i<n; i++){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	for(int i = 0; i<=n; i++){
		ans[i] = 1;
	}
	dfs(0,-1,0);
	for(int i = 0; i<n; i++){
		t->add(pre[i],pre[i],h[i]);
	}
	go(0,-1);
	for(int i = 1; i<=diam; i++){
		ans[i] = max(ans[i],2);
	}
	ans[1] = 0;
	ans[2] = 0;
	for(int i = 0; i<n; i++){
		ans[1] = max(ans[1],1+(int)adj[i].size());
		ans[2] = max(ans[2],(int)adj[i].size());
		for(int j = 0; j<adj[i].size(); j++){
			int to = adj[i][j];
			ans[2] = max(ans[2],(int)(adj[i].size()+adj[to].size()-2));
		}
	}
	for(int i = 1; i<=n; i++){
		cout << ans[i] << " ";
	}
	cout << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
class Node{
public:
	Node *l, *r;
	ll maxi, lazy;
	int s, e;
	Node(int a, int b){
		s = a;
		e = b;
		maxi = 0;
		lazy = 0;
		l = NULL;
		r = NULL;
		if(s!=e){
			l = new Node(s,(s+e)/2);
			r = new Node((s+e)/2+1,e);
		}
	}
	void push(){
		if(lazy!=0 && s!=e){
			l->maxi += lazy;
			l->lazy += lazy;
			r->maxi += lazy;
			r->lazy += lazy;
		}
		lazy = 0LL;
	}
	void pull(){
		if(s!=e){
			maxi = max(l->maxi,r->maxi);
		}
	}
	void add(int st, int en, ll val){
		push();
		if(st <= s && e <= en){
			maxi += val;
			lazy += val;
			return;
		}
		if(st <= (s+e)/2){
			l->add(st,en,val);
		}
		if(en>(s+e)/2){
			r->add(st,en,val);
		}
		pull();
	}
	ll gmax(int st, int en){
		push();
		if(st <= s && e <= en){
			return maxi;
		}
		ll ret = 0LL;
		if(st<=(s+e)/2){
			ret = max(ret,l->gmax(st,en));
		}
		if(en>(s+e)/2){
			ret = max(ret,r->gmax(st,en));
		}
		return ret;
	}
};
int pre[500000];
int post[500000];
int h[500000];
int bel[500000];
vector<int> adj[500000];
int point = 0;
int diam = 0;
int ans[500001];
void dfs(int now, int from, int cur){
	pre[now] = point++;
	bel[now] = 0;
	h[now] = cur;
	for(int i = 0; i<adj[now].size(); i++){
		int to = adj[now][i];
		if(to==from){
			continue;
		}
		dfs(to,now,cur+1);
		bel[now] = max(bel[now],1+bel[to]);
	}
	post[now] = point-1;
}
Node *t = NULL;
int n;
void addr(int l, int r, int x){
	if(l>0){
		t->add(0,l-1,x);
	}
	if(r<n-1){
		t->add(r+1,n-1,x);
	}
}
int maxr(int l, int r){
	int ret = 0;
	if(l>0){
		ret= max(ret,(int)(t->gmax(0,l-1)));
	}
	if(r<n-1){
		ret = max(ret,(int)(t->gmax(r+1,n-1)));
	}
	return ret;
}
void go(int now, int from){
	vector<int> b;

	for(int i = 0; i<adj[now].size(); i++){
		int to = adj[now][i];
		if(to==from){
			continue;
		}
		addr(pre[to],post[to],1);
		t->add(pre[to],post[to],-1);
		go(to,now);
		t->add(pre[to],post[to],1);
		addr(pre[to],post[to],-1);
		b.push_back(to);
	}
	vector<int> all;
	int zz = maxr(pre[now],post[now]);
	diam = max(diam,zz);
	all.push_back(zz);
	for(int i = 0; i<b.size(); i++){
		all.push_back(bel[b[i]]);
	}
	if(b.size()<=1){
		return;
	}
	sort(all.begin(),all.end());
	int p1 = 1;
	int p2 = 0;
	int rem = b.size();
	while(true){
		while(rem>=2 && p2<=all.size()-2 && (p1+1)/2>all[p2]){
			p2++;
			rem--;
		}
		if(rem>=2 && p2<=all.size()-2 && p1<=all[p2]){
			int val = rem;
			if(p1%2==1 && p2>0 && all[p2-1]>=p1/2){
				val++;
			}
			ans[p1] = max(ans[p1],val);
			p1++;
		}
		else{
			break;
		}
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	t = new Node(0,n-1);
	for(int i = 1; i<n; i++){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	for(int i = 0; i<=n; i++){
		ans[i] = 1;
	}
	dfs(0,-1,0);
	for(int i = 0; i<n; i++){
		t->add(i,i,h[i]);
	}
	go(0,-1);
	for(int i = 1; i<=diam; i++){
		ans[i] = max(ans[i],2);
	}
	ans[1] = 0;
	ans[2] = 0;
	for(int i = 0; i<n; i++){
		ans[1] = max(ans[1],1+(int)adj[i].size());
		ans[2] = max(ans[2],(int)adj[i].size());
		for(int j = 0; j<adj[i].size(); j++){
			int to = adj[i][j];
			ans[2] = max(ans[2],(int)(adj[i].size()+adj[to].size()-2));
		}
	}
	for(int i = 1; i<=n; i++){
		cout << ans[i] << " ";
	}
	cout << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
class Obj{
public:
	int deep, already;
	Obj(int b, int c){
		deep = b;
		already = c;
	}
};

class Node{
public:
	Node *l, *r;
	ll maxi, lazy;
	int s, e;
	Node(int a, int b){
		s = a;
		e = b;
		maxi = 0;
		lazy = 0;
		l = NULL;
		r = NULL;
		if(s!=e){
			l = new Node(s,(s+e)/2);
			r = new Node((s+e)/2+1,e);
		}
	}
	void push(){
		if(lazy!=0 && s!=e){
			l->maxi += lazy;
			l->lazy += lazy;
			r->maxi += lazy;
			r->lazy += lazy;
		}
		lazy = 0LL;
	}
	void pull(){
		if(s!=e){
			maxi = max(l->maxi,r->maxi);
		}
	}
	void add(int st, int en, ll val){
		push();
		if(st <= s && e <= en){
			maxi += val;
			lazy += val;
			return;
		}
		if(st <= (s+e)/2){
			l->add(st,en,val);
		}
		if(en>(s+e)/2){
			r->add(st,en,val);
		}
		pull();
	}
	ll gmax(int st, int en){
		push();
		if(st <= s && e <= en){
			return maxi;
		}
		ll ret = 0LL;
		if(st<=(s+e)/2){
			ret = max(ret,l->gmax(st,en));
		}
		if(en>(s+e)/2){
			ret = max(ret,r->gmax(st,en));
		}
		return ret;
	}
};
int pre[500000];
int post[500000];
int h[500000];
int bel[500000];
vector<int> adj[500000];
int point = 0;
int diam = 0;
int ans[500001];
vector<Obj> reqs[500001];
void dfs(int now, int from, int cur){
	pre[now] = point++;
	bel[now] = 0;
	h[now] = cur;
	for(int i = 0; i<adj[now].size(); i++){
		int to = adj[now][i];
		if(to==from){
			continue;
		}
		dfs(to,now,cur+1);
		bel[now] = max(bel[now],1+bel[to]);
	}
	post[now] = point-1;
}
Node *t = NULL;
int n;
void addr(int l, int r, int x){
	if(l>0){
		t->add(0,l-1,x);
	}
	if(r<n-1){
		t->add(r+1,n-1,x);
	}
}
int maxr(int l, int r){
	int ret = 0;
	if(l>0){
		ret= max(ret,(int)(t->gmax(0,l-1)));
	}
	if(r<n-1){
		ret = max(ret,(int)(t->gmax(r+1,n-1)));
	}
	return ret;
}
void go(int now, int from){
	vector<int> b;

	for(int i = 0; i<adj[now].size(); i++){
		int to = adj[now][i];
		if(to==from){
			continue;
		}
		addr(pre[to],post[to],1);
		t->add(pre[to],post[to],-1);
		go(to,now);
		t->add(pre[to],post[to],1);
		addr(pre[to],post[to],-1);
		b.push_back(to);
	}
	vector<int> all;
	int zz = maxr(pre[now],post[now]);
	diam = max(diam,zz);
	all.push_back(zz);
	for(int i = 0; i<b.size(); i++){
		all.push_back(bel[b[i]]+1);
	}
	if(b.size()<=1){
		return;
	}
	sort(all.begin(),all.end());
	int p1 = 2;
	int p2 = 0;
	int rem = all.size();
	b.clear();
	while(true){
		while(rem>=2 && p2<=all.size()-2 && (p1+1)/2>all[p2]){
			p2++;
			rem--;
		}
		if(rem>=2 && p2<=all.size()-2 && (p1+1)/2<=all[p2]){
			int val = rem;
			if(p1%2==1 && p2>0 && all[p2-1]>=p1/2){
				val++;
			}
			if(rem>=2 && p1%2==0 && all[all.size()-2]>=p1/2 && zz>=p1/2){
				reqs[from].push_back(Obj(p1/2,val));
			}
			ans[p1] = max(ans[p1],val);
			p1++;
		}
		else{
			break;
		}
	}
	all.clear();
}
void go2(int now, int from){
	vector<int> b;

	for(int i = 0; i<adj[now].size(); i++){
		int to = adj[now][i];
		if(to==from){
			continue;
		}
		addr(pre[to],post[to],1);
		t->add(pre[to],post[to],-1);
		go2(to,now);
		t->add(pre[to],post[to],1);
		addr(pre[to],post[to],-1);
		b.push_back(to);
	}
	vector<int> all;
	int zz = maxr(pre[now],post[now]);
	diam = max(diam,zz);
	all.push_back(zz);
	for(int i = 0; i<b.size(); i++){
		all.push_back(bel[b[i]]+1);
	}
	b.clear();
	sort(all.begin(),all.end());
	for(int i = 0; i<reqs[now].size(); i++){
		int deep = reqs[now][i].deep;
		int already = reqs[now][i].already;
		int lo = 1;
		int hi = all.size();
		while(lo<hi){
			int mid = (lo+hi+1)/2;
			if(all[all.size()-mid]>=deep){
				lo = mid;
			}
			else{
				hi = mid-1;
			}
		}
		ans[deep*2] = max(ans[deep*2],lo+already-2);
	}
	all.clear();
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	t = new Node(0,n-1);
	for(int i = 1; i<n; i++){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	for(int i = 0; i<=n; i++){
		ans[i] = 1;
	}
	dfs(0,-1,0);
	for(int i = 0; i<n; i++){
		t->add(pre[i],pre[i],h[i]);
	}
	go(0,-1);
	go2(0,-1);
	for(int i = 1; i<=diam; i++){
		ans[i] = max(ans[i],2);
	}
	ans[1] = 0;
	ans[2] = 0;
	for(int i = 0; i<n; i++){
		ans[1] = max(ans[1],1+(int)adj[i].size());
		ans[2] = max(ans[2],(int)adj[i].size());
		for(int j = 0; j<adj[i].size(); j++){
			int to = adj[i][j];
			ans[2] = max(ans[2],(int)(adj[i].size()+adj[to].size()-2));
		}
	}
	for(int i = 1; i<=n; i++){
		cout << ans[i] << " ";
	}
	cout << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
class Obj{
public:
	int deep, already;
	Obj(int b, int c){
		deep = b;
		already = c;
	}
};

class Node{
public:
	Node *l, *r;
	ll maxi, lazy;
	int s, e;
	Node(int a, int b){
		s = a;
		e = b;
		maxi = 0;
		lazy = 0;
		l = NULL;
		r = NULL;
		if(s!=e){
			l = new Node(s,(s+e)/2);
			r = new Node((s+e)/2+1,e);
		}
	}
	void push(){
		if(lazy!=0 && s!=e){
			l->maxi += lazy;
			l->lazy += lazy;
			r->maxi += lazy;
			r->lazy += lazy;
		}
		lazy = 0LL;
	}
	void pull(){
		if(s!=e){
			maxi = max(l->maxi,r->maxi);
		}
	}
	void add(int st, int en, ll val){
		push();
		if(st <= s && e <= en){
			maxi += val;
			lazy += val;
			return;
		}
		if(st <= (s+e)/2){
			l->add(st,en,val);
		}
		if(en>(s+e)/2){
			r->add(st,en,val);
		}
		pull();
	}
	ll gmax(int st, int en){
		push();
		if(st <= s && e <= en){
			return maxi;
		}
		ll ret = 0LL;
		if(st<=(s+e)/2){
			ret = max(ret,l->gmax(st,en));
		}
		if(en>(s+e)/2){
			ret = max(ret,r->gmax(st,en));
		}
		return ret;
	}
};
int pre[500000];
int post[500000];
int h[500000];
int bel[500000];
vector<int> adj[500000];
int point = 0;
int diam = 0;
int ans[500001];
vector<Obj> reqs[500001];
void dfs(int now, int from, int cur){
	pre[now] = point++;
	bel[now] = 0;
	h[now] = cur;
	for(int i = 0; i<adj[now].size(); i++){
		int to = adj[now][i];
		if(to==from){
			continue;
		}
		dfs(to,now,cur+1);
		bel[now] = max(bel[now],1+bel[to]);
	}
	post[now] = point-1;
}
Node *t = NULL;
int n;
void addr(int l, int r, int x){
	if(l>0){
		t->add(0,l-1,x);
	}
	if(r<n-1){
		t->add(r+1,n-1,x);
	}
}
int maxr(int l, int r){
	int ret = 0;
	if(l>0){
		ret= max(ret,(int)(t->gmax(0,l-1)));
	}
	if(r<n-1){
		ret = max(ret,(int)(t->gmax(r+1,n-1)));
	}
	return ret;
}
void go(int now, int from){
	vector<int> b;

	for(int i = 0; i<adj[now].size(); i++){
		int to = adj[now][i];
		if(to==from){
			continue;
		}
		addr(pre[to],post[to],1);
		t->add(pre[to],post[to],-1);
		go(to,now);
		t->add(pre[to],post[to],1);
		addr(pre[to],post[to],-1);
		b.push_back(to);
	}
	vector<int> all;
	int zz = maxr(pre[now],post[now]);
	diam = max(diam,zz);
	all.push_back(zz);
	for(int i = 0; i<b.size(); i++){
		all.push_back(bel[b[i]]+1);
	}
	if(b.size()<=1){
		return;
	}
	sort(all.begin(),all.end());
	int p1 = 2;
	int p2 = 0;
	int rem = all.size();
	b.clear();
	while(true){
		while(rem>=3 && p2<=all.size()-2 && (p1+1)/2>all[p2]){
			p2++;
			rem--;
		}
		if(rem>=3 && p2<=all.size()-2 && (p1+1)/2<=all[p2]){
			int val = rem;
			if(p1%2==1 && p2>0 && all[p2-1]>=p1/2){
				val++;
			}
			if(p1%2==0 && all[all.size()-2]>=p1/2 && zz>=p1/2){
				reqs[from].push_back(Obj(p1/2,val));
			}
			ans[p1] = max(ans[p1],val);
			p1++;
		}
		else{
			break;
		}
	}
	all.clear();
}
void go2(int now, int from){
	vector<int> b;

	for(int i = 0; i<adj[now].size(); i++){
		int to = adj[now][i];
		if(to==from){
			continue;
		}
		addr(pre[to],post[to],1);
		t->add(pre[to],post[to],-1);
		go2(to,now);
		t->add(pre[to],post[to],1);
		addr(pre[to],post[to],-1);
		b.push_back(to);
	}
	vector<int> all;
	int zz = maxr(pre[now],post[now]);
	diam = max(diam,zz);
	all.push_back(zz);
	for(int i = 0; i<b.size(); i++){
		all.push_back(bel[b[i]]+1);
	}
	b.clear();
	sort(all.begin(),all.end());
	for(int i = 0; i<reqs[now].size(); i++){
		int deep = reqs[now][i].deep;
		int already = reqs[now][i].already;
		int lo = 1;
		int hi = all.size();
		while(lo<hi){
			int mid = (lo+hi+1)/2;
			if(all[all.size()-mid]>=deep){
				lo = mid;
			}
			else{
				hi = mid-1;
			}
		}
		ans[deep*2] = max(ans[deep*2],lo+already-2);
	}
	all.clear();
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	t = new Node(0,n-1);
	for(int i = 1; i<n; i++){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	for(int i = 0; i<=n; i++){
		ans[i] = 1;
	}
	dfs(0,-1,0);
	for(int i = 0; i<n; i++){
		t->add(pre[i],pre[i],h[i]);
	}
	go(0,-1);
	go2(0,-1);
	for(int i = 1; i<=diam; i++){
		ans[i] = max(ans[i],2);
	}
	ans[1] = 0;
	ans[2] = 0;
	for(int i = 0; i<n; i++){
		ans[1] = max(ans[1],1+(int)adj[i].size());
		ans[2] = max(ans[2],(int)adj[i].size());
		for(int j = 0; j<adj[i].size(); j++){
			int to = adj[i][j];
			ans[2] = max(ans[2],(int)(adj[i].size()+adj[to].size()-2));
		}
	}
	for(int i = 1; i<=n; i++){
		cout << ans[i] << " ";
	}
	cout << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
class Obj{
public:
	int deep, already;
	Obj(int b, int c){
		deep = b;
		already = c;
	}
};

class Node{
public:
	Node *l, *r;
	ll maxi, lazy;
	int s, e;
	Node(int a, int b){
		s = a;
		e = b;
		maxi = 0;
		lazy = 0;
		l = NULL;
		r = NULL;
		if(s!=e){
			l = new Node(s,(s+e)/2);
			r = new Node((s+e)/2+1,e);
		}
	}
	void push(){
		if(lazy!=0 && s!=e){
			l->maxi += lazy;
			l->lazy += lazy;
			r->maxi += lazy;
			r->lazy += lazy;
		}
		lazy = 0LL;
	}
	void pull(){
		if(s!=e){
			maxi = max(l->maxi,r->maxi);
		}
	}
	void add(int st, int en, ll val){
		push();
		if(st <= s && e <= en){
			maxi += val;
			lazy += val;
			return;
		}
		if(st <= (s+e)/2){
			l->add(st,en,val);
		}
		if(en>(s+e)/2){
			r->add(st,en,val);
		}
		pull();
	}
	ll gmax(int st, int en){
		push();
		if(st <= s && e <= en){
			return maxi;
		}
		ll ret = 0LL;
		if(st<=(s+e)/2){
			ret = max(ret,l->gmax(st,en));
		}
		if(en>(s+e)/2){
			ret = max(ret,r->gmax(st,en));
		}
		return ret;
	}
};
int pre[500000];
int post[500000];
int h[500000];
int bel[500000];
vector<int> adj[500000];
int point = 0;
int diam = 0;
int ans[500001];
vector<Obj> reqs[500001];
void dfs(int now, int from, int cur){
	pre[now] = point++;
	bel[now] = 0;
	h[now] = cur;
	for(int i = 0; i<adj[now].size(); i++){
		int to = adj[now][i];
		if(to==from){
			continue;
		}
		dfs(to,now,cur+1);
		bel[now] = max(bel[now],1+bel[to]);
	}
	post[now] = point-1;
}
Node *t = NULL;
int n;
void addr(int l, int r, int x){
	if(l>0){
		t->add(0,l-1,x);
	}
	if(r<n-1){
		t->add(r+1,n-1,x);
	}
}
int maxr(int l, int r){
	int ret = 0;
	if(l>0){
		ret= max(ret,(int)(t->gmax(0,l-1)));
	}
	if(r<n-1){
		ret = max(ret,(int)(t->gmax(r+1,n-1)));
	}
	return ret;
}
void go(int now, int from){
	vector<int> b;

	for(int i = 0; i<adj[now].size(); i++){
		int to = adj[now][i];
		if(to==from){
			continue;
		}
		addr(pre[to],post[to],1);
		t->add(pre[to],post[to],-1);
		go(to,now);
		t->add(pre[to],post[to],1);
		addr(pre[to],post[to],-1);
		b.push_back(to);
	}
	vector<int> all;
	int zz = maxr(pre[now],post[now]);
	diam = max(diam,zz);
	all.push_back(zz);
	for(int i = 0; i<b.size(); i++){
		all.push_back(bel[b[i]]+1);
	}
	if(b.size()<=1){
		return;
	}
	sort(all.begin(),all.end());
	int p1 = 2;
	int p2 = 0;
	int rem = all.size();
	b.clear();
	while(true){
		while(rem>=2 && p2<=all.size()-2 && (p1+1)/2>all[p2]){
			p2++;
			rem--;
		}
		if(rem>=2 && p2<=all.size()-2 && (p1+1)/2<=all[p2]){
			int val = rem;
			if(p1%2==1 && p2>0 && all[p2-1]>=p1/2){
				val++;
			}
			if(rem>2 && p1%2==0 && all[all.size()-2]>=p1/2 && zz>=p1/2){
				reqs[from].push_back(Obj(p1/2,val));
			}
			ans[p1] = max(ans[p1],val);
			p1++;
		}
		else{
			break;
		}
	}
	all.clear();
}
void go2(int now, int from){
	vector<int> b;

	for(int i = 0; i<adj[now].size(); i++){
		int to = adj[now][i];
		if(to==from){
			continue;
		}
		addr(pre[to],post[to],1);
		t->add(pre[to],post[to],-1);
		go2(to,now);
		t->add(pre[to],post[to],1);
		addr(pre[to],post[to],-1);
		b.push_back(to);
	}
	vector<int> all;
	int zz = maxr(pre[now],post[now]);
	diam = max(diam,zz);
	all.push_back(zz);
	for(int i = 0; i<b.size(); i++){
		all.push_back(bel[b[i]]+1);
	}
	b.clear();
	sort(all.begin(),all.end());
	for(int i = 0; i<reqs[now].size(); i++){
		int deep = reqs[now][i].deep;
		int already = reqs[now][i].already;
		int lo = 1;
		int hi = all.size();
		while(lo<hi){
			int mid = (lo+hi+1)/2;
			if(all[all.size()-mid]>=deep){
				lo = mid;
			}
			else{
				hi = mid-1;
			}
		}
		ans[deep*2] = max(ans[deep*2],lo+already-2);
	}
	all.clear();
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	t = new Node(0,n-1);
	for(int i = 1; i<n; i++){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	for(int i = 0; i<=n; i++){
		ans[i] = 1;
	}
	dfs(0,-1,0);
	for(int i = 0; i<n; i++){
		t->add(pre[i],pre[i],h[i]);
	}
	go(0,-1);
	go2(0,-1);
	for(int i = 1; i<=diam; i++){
		ans[i] = max(ans[i],2);
	}
	ans[1] = 0;
	ans[2] = 0;
	for(int i = 0; i<n; i++){
		ans[1] = max(ans[1],1+(int)adj[i].size());
		ans[2] = max(ans[2],(int)adj[i].size());
		for(int j = 0; j<adj[i].size(); j++){
			int to = adj[i][j];
			ans[2] = max(ans[2],(int)(adj[i].size()+adj[to].size()-2));
		}
	}
	for(int i = 1; i<=n; i++){
		cout << ans[i] << " ";
	}
	cout << endl;
}


#include <bits/stdc++.h>
using namespace std;

typedef pair <int, int> pii;

const int MAXN = 5e5 + 5;

int N;
vector <int> adj[MAXN];
vector <pii> ch[MAXN];
int mx1[MAXN], mx2[MAXN];
int up[MAXN];
int ans[MAXN];

void load() {
	scanf("%d", &N);
	for (int i = 1; i < N; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
}

int dfs_down(int x, int p) {
	for (auto it : adj[x])
		if (it != p) {
			int tmp = dfs_down(it, x) + 1;
			ch[x].push_back({it, tmp});
			if (tmp >= mx1[x]) {
				mx2[x] = mx1[x];
				mx1[x] = tmp;
			}
			else if (tmp > mx2[x])
				mx2[x] = tmp;
		}
	return mx1[x];
}

void dfs_up(int x) {
	for (auto it : ch[x]) {
		up[it.first] = max(up[x], it.second == mx1[x] ? mx2[x] : mx1[x]) + 1;
		dfs_up(it.first);
	}
}

inline void update(int x, int val) {
	if (x <= N && val > 1 && val > ans[x])
		ans[x] = val;
}

void dfs_calc(int x, int above, const vector <pii> &par) {
	map <int, int> tmp;
	tmp[0]++;
	tmp[up[x]]++;
	for (auto it : ch[x])
		tmp[it.second]++;

	vector <pii> imp;
	for (auto it = tmp.rbegin(); it != tmp.rend(); it++)
		imp.push_back(*it);

	int geq = 0;
	for (auto it : imp) {
		geq += it.second;
		update(2 * it.first, geq);
		update(2 * it.first - 1, geq);
		update(2 * it.first + 1, geq - it.second + 1);
	}

	for (auto it : ch[x])
		dfs_calc(it.first, it.second, imp);

	vector <pii> nxt(imp.size() + par.size());
	merge(imp.begin(), imp.end(), par.begin(), par.end(), nxt.begin(), greater <pii> ());
	imp.clear();
	for (int i = 0; i < nxt.size(); i++)
		if (i < (int)nxt.size() - 1 && nxt[i].first == nxt[i + 1].first) {
			imp.push_back({nxt[i].first, nxt[i].second + nxt[i + 1].second});
			i++;
		}
		else
			imp.push_back(nxt[i]);

	geq = 0;
	for (auto it : imp) {
		geq += it.second;
		update(2 * it.first, geq - (above >= it.first) - (up[x] >= it.first));
	}
}

void solve() {
	dfs_down(1, 0);
	dfs_up(1);
	dfs_calc(1, 0, {});

	for (int i = N; i; i--)
		ans[i] = max(ans[i], ans[i + 2]);

	for (int i = 1; i <= N; i++)
		printf("%d ", max(ans[i], 1));
	puts("");
}

int main() {
	load();
	solve();
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef pair <int, int> pii;

const int MAXN = 5e5 + 5;

int N;
vector <int> adj[MAXN];
map <int, int> imp[MAXN], all[MAXN];
vector <pii> ch[MAXN];
multiset <int> down[MAXN];
int up[MAXN];
int ans[MAXN];

void load() {
	scanf("%d", &N);
	for (int i = 1; i < N; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
}

int dfs_down(int x, int p) {
	down[x].insert(0);
	for (auto it : adj[x])
		if (it != p) {
			int tmp = dfs_down(it, x) + 1;
			ch[x].push_back({it, tmp});
			down[x].insert(tmp);
		}
	return *down[x].rbegin();
}

void dfs_up(int x) {
	for (auto it : ch[x]) {
		down[x].erase(down[x].find(it.second));
		up[it.first] = max(up[x], *down[x].rbegin()) + 1;
		down[x].insert(it.second);
		dfs_up(it.first);
	}
}

inline void update(int x, int val) {
	if (x <= N && val > 1 && val > ans[x])
		ans[x] = val;
}

void dfs_calc(int x, int above) {
	imp[x][up[x]]++;
	for (auto it : down[x])
		imp[x][it]++;

	int geq = 0;
	for (auto it = imp[x].rbegin(); it != imp[x].rend(); it++) {
		int k = it -> first;
		int cnt = it -> second;
		geq += cnt;
		update(2 * k, geq);
		update(2 * k - 1, geq);
		update(2 * k + 1, geq - cnt + 1);
		all[x][k] += cnt;
		for (auto child : ch[x])
			all[child.first][k] += cnt;
	}

	geq = 0;
	for (auto it = all[x].rbegin(); it != all[x].rend(); it++) {
		int k = it -> first;
		geq += it -> second;
		update(2 * k, geq - (above >= k) - (up[x] >= k));
	}

	for (auto it : ch[x])
		dfs_calc(it.first, it.second);
}

void solve() {
	dfs_down(1, 0);
	dfs_up(1);
	dfs_calc(1, 0);

	for (int i = N; i; i--)
		ans[i] = max(ans[i], ans[i + 2]);

	for (int i = 1; i <= N; i++)
		printf("%d ", max(ans[i], 1));
	puts("");
}

int main() {
	load();
	solve();
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef pair <int, int> pii;

const int MAXN = 5e5 + 5;

int N;
vector <int> adj[MAXN];
map <int, int> imp[MAXN], all[MAXN];
vector <pii> ch[MAXN];
int mx1[MAXN], mx2[MAXN];
int up[MAXN];
int ans[MAXN];

void load() {
	scanf("%d", &N);
	for (int i = 1; i < N; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
}

int dfs_down(int x, int p) {
	for (auto it : adj[x])
		if (it != p) {
			int tmp = dfs_down(it, x) + 1;
			ch[x].push_back({it, tmp});
			if (tmp >= mx1[x]) {
				mx2[x] = mx1[x];
				mx1[x] = tmp;
			}
			else if (tmp > mx2[x])
				mx2[x] = tmp;
			imp[x][tmp]++;
		}
	return mx1[x];
}

void dfs_up(int x) {
	imp[x][0]++;
	imp[x][up[x]]++;
	for (auto it : ch[x]) {
		up[it.first] = max(up[x], it.second == mx1[x] ? mx2[x] : mx1[x]) + 1;
		dfs_up(it.first);
	}
}

inline void update(int x, int val) {
	if (x <= N && val > 1 && val > ans[x])
		ans[x] = val;
}

void dfs_calc(int x, int above) {
	int geq = 0;
	for (auto it = imp[x].rbegin(); it != imp[x].rend(); it++) {
		int k = it -> first;
		int cnt = it -> second;
		geq += cnt;
		update(2 * k, geq);
		update(2 * k - 1, geq);
		update(2 * k + 1, geq - cnt + 1);
		all[x][k] += cnt;
		for (auto child : ch[x])
			all[child.first][k] += cnt;
	}

	geq = 0;
	for (auto it = all[x].rbegin(); it != all[x].rend(); it++) {
		int k = it -> first;
		geq += it -> second;
		update(2 * k, geq - (above >= k) - (up[x] >= k));
	}

	for (auto it : ch[x])
		dfs_calc(it.first, it.second);
}

void solve() {
	dfs_down(1, 0);
	dfs_up(1);
	dfs_calc(1, 0);

	for (int i = N; i; i--)
		ans[i] = max(ans[i], ans[i + 2]);

	for (int i = 1; i <= N; i++)
		printf("%d ", max(ans[i], 1));
	puts("");
}

int main() {
	load();
	solve();
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef pair <int, int> pii;

const int MAXN = 5e5 + 5;

int N;
vector <int> adj[MAXN];
map <int, int> imp[MAXN], all[MAXN];
vector <pii> ch[MAXN];
multiset <int> down[MAXN];
int up[MAXN];
int ans[MAXN];

void load() {
	scanf("%d", &N);
	for (int i = 1; i < N; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
}

int dfs_down(int x, int p) {
	down[x].insert(0);
	for (auto it : adj[x])
		if (it != p) {
			int tmp = dfs_down(it, x) + 1;
			ch[x].push_back({it, tmp});
			down[x].insert(tmp);
		}
	return *down[x].rbegin();
}

void dfs_up(int x) {
	for (auto it : ch[x]) {
		down[x].erase(down[x].find(it.second));
		up[it.first] = max(up[x], *down[x].rbegin()) + 1;
		down[x].insert(it.second);
		dfs_up(it.first);
	}
}

inline void update(int x, int val) {
	if (val > ans[x])
		ans[x] = val;
}

void dfs_calc(int x, int above) {
	imp[x][up[x]]++;
	for (auto it : down[x])
		imp[x][it]++;

	int geq = 0;
	for (auto it = imp[x].rbegin(); it != imp[x].rend(); it++) {
		int k = it -> first;
		int cnt = it -> second;
		geq += cnt;
		update(2 * k, geq);
		update(2 * k - 1, geq);
		update(2 * k + 1, geq - cnt + 1);
		all[x][k] += cnt;
		for (auto child : ch[x])
			all[child.first][k] += cnt;
	}

	geq = 0;
	for (auto it = all[x].rbegin(); it != all[x].rend(); it++) {
		int k = it -> first;
		geq += it -> second;
		update(2 * k, geq - (above >= k) - (up[x] >= k));
	}

	for (auto it : ch[x])
		dfs_calc(it.first, it.second);
}

void solve() {
	dfs_down(1, 0);
	dfs_up(1);
	dfs_calc(1, 0);

	for (int i = N; i; i--)
		ans[i] = max(ans[i], ans[i + 2]);

	for (int i = 1; i <= N; i++)
		printf("%d ", ans[i]);
	puts("");
}

int main() {
	load();
	solve();
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef pair <int, int> pii;

const int MAXN = 5e5 + 5;

int N;
vector <int> adj[MAXN];
map <int, int> imp[MAXN];
vector <pii> ch[MAXN];
int mx1[MAXN], mx2[MAXN];
int up[MAXN];
int ans[MAXN];

void load() {
	scanf("%d", &N);
	for (int i = 1; i < N; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
}

int dfs_down(int x, int p) {
	for (auto it : adj[x])
		if (it != p) {
			int tmp = dfs_down(it, x) + 1;
			ch[x].push_back({it, tmp});
			if (tmp >= mx1[x]) {
				mx2[x] = mx1[x];
				mx1[x] = tmp;
			}
			else if (tmp > mx2[x])
				mx2[x] = tmp;
			imp[x][tmp]++;
		}
	return mx1[x];
}

void dfs_up(int x) {
	imp[x][0]++;
	imp[x][up[x]]++;
	for (auto it : ch[x]) {
		up[it.first] = max(up[x], it.second == mx1[x] ? mx2[x] : mx1[x]) + 1;
		dfs_up(it.first);
	}
}

inline void update(int x, int val) {
	if (x <= N && val > 1 && val > ans[x])
		ans[x] = val;
}

void dfs_calc(int x, int above, int p) {
	int geq = 0;
	for (auto it = imp[x].rbegin(); it != imp[x].rend(); it++) {
		int k = it -> first;
		int cnt = it -> second;
		geq += cnt;
		update(2 * k, geq);
		update(2 * k - 1, geq);
		update(2 * k + 1, geq - cnt + 1);
	}

	for (auto it : ch[x])
		dfs_calc(it.first, it.second, x);

	for (auto it : imp[p])
		imp[x][it.first] += it.second;

	geq = 0;
	for (auto it = imp[x].rbegin(); it != imp[x].rend(); it++) {
		int k = it -> first;
		geq += it -> second;
		update(2 * k, geq - (above >= k) - (up[x] >= k));
	}
}

void solve() {
	dfs_down(1, 0);
	dfs_up(1);
	dfs_calc(1, 0, 0);

	for (int i = N; i; i--)
		ans[i] = max(ans[i], ans[i + 2]);

	for (int i = 1; i <= N; i++)
		printf("%d ", max(ans[i], 1));
	puts("");
}

int main() {
	load();
	solve();
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef pair <int, int> pii;

const int MAXN = 5e5 + 5;

int N;
vector <int> adj[MAXN];
vector <pii> ch[MAXN];
int mx1[MAXN], mx2[MAXN];
int up[MAXN];
int ans[MAXN];

void load() {
	scanf("%d", &N);
	for (int i = 1; i < N; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
}

int dfs_down(int x, int p) {
	for (auto it : adj[x])
		if (it != p) {
			int tmp = dfs_down(it, x) + 1;
			ch[x].push_back({it, tmp});
			if (tmp >= mx1[x]) {
				mx2[x] = mx1[x];
				mx1[x] = tmp;
			}
			else if (tmp > mx2[x])
				mx2[x] = tmp;
		}
	return mx1[x];
}

void dfs_up(int x) {
	for (auto it : ch[x]) {
		up[it.first] = max(up[x], it.second == mx1[x] ? mx2[x] : mx1[x]) + 1;
		dfs_up(it.first);
	}
}

inline void update(int x, int val) {
	if (x <= N && val > 1 && val > ans[x])
		ans[x] = val;
}

void dfs_calc(int x, int above, const map <int, int> &par) {
	map <int, int> imp;
	imp[0]++;
	imp[up[x]]++;
	for (auto it : ch[x])
		imp[it.second]++;

	int geq = 0;
	for (auto it = imp.rbegin(); it != imp.rend(); it++) {
		int k = it -> first;
		int cnt = it -> second;
		geq += cnt;
		update(2 * k, geq);
		update(2 * k - 1, geq);
		update(2 * k + 1, geq - cnt + 1);
	}

	for (auto it : ch[x])
		dfs_calc(it.first, it.second, imp);

	for (auto it : par)
		imp[it.first] += it.second;

	geq = 0;
	for (auto it = imp.rbegin(); it != imp.rend(); it++) {
		int k = it -> first;
		geq += it -> second;
		update(2 * k, geq - (above >= k) - (up[x] >= k));
	}
}

void solve() {
	dfs_down(1, 0);
	dfs_up(1);
	dfs_calc(1, 0, {});

	for (int i = N; i; i--)
		ans[i] = max(ans[i], ans[i + 2]);

	for (int i = 1; i <= N; i++)
		printf("%d ", max(ans[i], 1));
	puts("");
}

int main() {
	load();
	solve();
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef pair <int, int> pii;

const int MAXN = 5e5 + 5;

int N;
vector <int> adj[MAXN];
map <int, int> imp[MAXN], all[MAXN];
vector <pii> ch[MAXN];
int mx1[MAXN], mx2[MAXN];
int up[MAXN];
int ans[MAXN];

void load() {
	scanf("%d", &N);
	for (int i = 1; i < N; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
}

int dfs_down(int x, int p) {
	for (auto it : adj[x])
		if (it != p) {
			int tmp = dfs_down(it, x) + 1;
			ch[x].push_back({it, tmp});
			if (tmp >= mx1[x]) {
				mx2[x] = mx1[x];
				mx1[x] = tmp;
			}
			else if (tmp > mx2[x])
				mx2[x] = tmp;
			imp[x][tmp]++;
		}
	return mx1[x];
}

void dfs_up(int x) {
	imp[x][up[x]]++;
	for (auto it : ch[x]) {
		up[it.first] = max(up[x], it.second == mx1[x] ? mx2[x] : mx1[x]) + 1;
		dfs_up(it.first);
	}
}

inline void update(int x, int val) {
	if (x <= N && val > 1 && val > ans[x])
		ans[x] = val;
}

void dfs_calc(int x, int above) {
	int geq = 0;
	for (auto it = imp[x].rbegin(); it != imp[x].rend(); it++) {
		int k = it -> first;
		int cnt = it -> second;
		geq += cnt;
		update(2 * k, geq);
		update(2 * k - 1, geq);
		update(2 * k + 1, geq - cnt + 1);
		all[x][k] += cnt;
		for (auto child : ch[x])
			all[child.first][k] += cnt;
	}

	geq = 0;
	for (auto it = all[x].rbegin(); it != all[x].rend(); it++) {
		int k = it -> first;
		geq += it -> second;
		update(2 * k, geq - (above >= k) - (up[x] >= k));
	}

	for (auto it : ch[x])
		dfs_calc(it.first, it.second);
}

void solve() {
	dfs_down(1, 0);
	dfs_up(1);
	dfs_calc(1, 0);

	for (int i = N; i; i--)
		ans[i] = max(ans[i], ans[i + 2]);

	for (int i = 1; i <= N; i++)
		printf("%d ", max(ans[i], 1));
	puts("");
}

int main() {
	load();
	solve();
	return 0;
}