#include <iostream>
#include <cmath>
#include <utility>
#include <vector>

using namespace std;

#define mp make_pair
#define x first
#define y second
typedef pair<int,int> pii;
typedef long long ll;

ll siz[200005],depth[200005],sol[200005];
int anc[20][200005],st[200005],en[200005],cnt;
vector<int> veki[200005];

ll dfs(int x,int p){
	depth[x]=depth[p]+1ll;
	cnt++;
	st[x]=cnt;
	siz[x]=1ll;
	anc[0][x]=p;
	for(int i=0;i<veki[x].size();i++){
		int v=veki[x][i];
		if(p==v) continue;
		siz[x]+=dfs(v,x);
	}
	cnt++;
	en[x]=cnt;
	return siz[x];
}

void lca_prep(ll n){
	for(int i=1;i<19;i++){
		for(int j=1;j<=n;j++){
			anc[i][j]=anc[i-1][anc[i-1][j]];
		}
	}
}
int getanc(int x,int k){
	for(int i=0;i<19;i++){
		if((k&(1<<i))) x=anc[i][x];
	}
	return x;
}
int lca(int x,int y){
	if(depth[x]<depth[y]) swap(x,y);
	x=getanc(x,depth[x]-depth[y]);
	if(x==y) return x;
	for(int i=18;i>=0;i--){
		if(anc[i][x]!=anc[i][y]){
			x=anc[i][x];
			y=anc[i][y];
		}
	}
	return anc[0][x];
}
int check(int x,int y){
	if(st[x]>=st[y] and en[x]<=en[y]) return 1;
	return 0;
}


int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t;
	cin>>t;
	while(t--){
		ll n;
		cin>>n;
		for(int i=1;i<n;i++){
			int a,b;
			cin>>a>>b;
			veki[a+1].push_back(b+1);
			veki[b+1].push_back(a+1);
		}
		sol[0]=n*(n-1ll)/2ll;
		dfs(1,0);
		lca_prep(n);
		ll add=0ll;
		for(int i=0;i<veki[1].size();i++){
			add+=siz[veki[1][i]]*(siz[veki[1][i]]-1ll)/2ll;
		}
		sol[1]=sol[0]-add;
		int k1=1,k2=2;
		for(int i=2;i<=n;i++){
			int l=lca(k1,k2);
			if(l==k1 or l==k2){
				if(depth[k1]>depth[k2]) swap(k1,k2);
				int fc=getanc(k2,depth[k2]-depth[k1]-1);
				sol[i]=siz[k2]*(siz[k1]-siz[fc]);
			}
			else{
				sol[i]=siz[k1]*siz[k2];
			}
			int nd=i+1;
			if(l!=k1 and l!=k2){
				if(check(nd,l)){
					if(check(nd,k1)) k1=nd;
					else if(check(nd,k2)) k2=nd;
					else if(check(k1,nd) or check(k2,nd)) continue;
					else break;
				}
				else break;
			}
			else{
				if(check(nd,k2)) k2=nd;
				else if(check(k2,nd)) continue;
				else if(lca(nd,k2)==k1) k1=nd;
				else break;
			}
		}
		for(int i=1;i<=n+1;i++){
			cout<<sol[i-1]-sol[i]<<" ";
		}
		cout<<"\n";
		for(int i=1;i<=n;i++){
			for(int j=0;j<19;j++) anc[j][i]=0;
			sol[i]=depth[i]=siz[i]=st[i]=en[i]=0;
			veki[i].clear();
		}
	}




return 0;
}

