#include<bits/stdc++.h>
#define PII pair<int,int>
#define fir first
#define sec second
using namespace std;
const int N=1e6+5,P=1e9+7;
int n,K,v[N];
struct edge{int x,y;}e[N];
int main(){
	freopen("traverse.in","r",stdin);
	freopen("traverse.out","w",stdout);
	int C,T;scanf("%d%d",&C,&T);
	while(T--){
		scanf("%d%d",&n,&K);
		memset(v,0,sizeof(v));
		for(int i=1;i<n;i++){
			int x,y;scanf("%d%d",&x,&y);
			e[i]={x,y};
		}
		for(int i=1;i<=K;i++){
			int x;scanf("%d",&x);
			v[x]=1;
		}
		int ans=K*2;
		if(v[1])ans--;
		if(v[n])ans--;
		if(v[1]&&v[n])ans--;
		printf("%d\n",ans);
	}
	return 0;
} 
