#include<bits/stdc++.h>
#define int long long
using namespace std;
void solve(){
	int n,k; cin>>n>>k;
	vector<vector<int>> g(n+1);
	vector<int> siz(n+1,0);
	for(int i=1;i<n;i++){
		int u,v; cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	for(int i=1;i<=k;i++){
		int x; cin>>x;
	}
	auto dfs=[&](auto self,int u,int pre)->void{
		bool flag=0;
		for(int v:g[u]){
			if(v==pre) continue;
			flag=1;
			self(self,v,u);
			siz[u]+=siz[v];
		}
		if(!flag) siz[u]=1;
	};
	dfs(dfs,1,0);
	cout<<siz[1]<<"\n";
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	freopen("traverse.in","r",stdin);
	freopen("traverse.out","w",stdout);
	int c,t; cin>>c>>t;
	while(t--) solve();
	return 0;
}
