#include <bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int c,T;
int n,k,x,y;
int e[100001];
int a[1001][1001];
int b[100001][3];
void dfs(int x,int sum){
	for(int i=1;i<=n;i++){
		if(a[x][i]==1){
			a[x][i]=2;
			dfs(a[x][i],sum+1);
		}
	}
}
int main()
{
//	freopen("traverse.in","r",stdin);
//	freopen("traverse.out","w",stdout);
	cin>>c>>T;
	while(T--){
		cin>>n>>k;
		for(int i=1;i<n;i++){
			scanf("%d%d",&x,&y);
			a[x][y]=1;
			a[y][x]=1;
			b[i][1]=x;
			b[i][2]=y;
		}
		for(int i=1;i<=k;i++) scanf("%d",&e[i]);
		if(k==1){
			dfs(e[1],1);
		}
	}
}
