#include<bits/stdc++.h>
#define pb push_back
using namespace std;
const int N=1e5+5,P=1e9+7;
int T,n,k,u[N],v[N],ans;
vector<int>e[N];
inline void dfs(int u,int fa){
	for(int v:e[u])if(v^fa){dfs(v,u);}
	if(e[u][0]==fa&&e[u].size()==1)ans++;
}
inline void mian(){
	cin>>n>>k;ans=0;
	for(int i=1;i<n;i++)
		cin>>u[i]>>v[i],e[u[i]].pb(v[i]),e[v[i]].pb(u[i]);
	for(int i=1,id;i<=k;i++){
		cin>>id;dfs(id,0);
	}cout<<ans<<'\n';
}
int main(){
	freopen("traverse.in","r",stdin);
	freopen("traverse.out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>T;cin>>T;while(T--)mian();
	return 0;
}
