#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int c,_,n,k,U,V,imp[N],x;
vector<int>e[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>>c>>_;
	while(_--){
		cin>>n>>k;
		for(int i=1;i<=n;i++)imp[i]=0;
		for(int i=1;i<n;i++){
			cin>>U>>V;
			e[U].push_back(V);
			e[V].push_back(U);
		}
		for(int i=1;i<=k;i++){
			cin>>x;
			imp[x]=1;
		}
		cout<<k-1<<"\n";
	}
	return 0;
}
