#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
long long c,ttt,n,k,head[100005],to[200005],nxt[200005],cnt,h,ans;
long long uu[100005],vv[100005];
void add(long long u,long long v)
{
	nxt[++cnt]=head[u];
	head[u]=cnt;
	to[cnt]=v;
}
int main()
{
	freopen("traverse.in","r",stdin);
	freopen("traverse.out","w",stdout);
	scanf("%lld%lld",&c,&ttt);
	while(ttt--)
	{
		scanf("%lld%lld",&n,&k);
		cnt=0;
		for(int i=1;i<=n;i++) head[i]=0;
		for(int i=1;i<n;i++)
		{
			scanf("%lld%lld",&uu[i],&vv[i]);
			add(uu[i],vv[i]);add(vv[i],uu[i]);
		}
		for(int i=1;i<=k;i++)
		{
			scanf("%lld",&h);
		}
		printf("%lld\n",ans);
	}
	return 0;
}
