#include<bits/stdc++.h>
using namespace std;
int id,T;
int n,k;
int head[150000],cnt;
struct edge
{
	int nxt,to;
}e[250000];
void link(int x,int y)
{
	cnt++;
	e[cnt].nxt=head[x];
	e[cnt].to=y;
	head[x]=cnt;
}
int main()
{
	freopen("traverse.in","r",stdin);
	freopen("traverse.out","w",stdout);
	scanf("%d%d",&id,&T);
	while(T--)
	{
		scanf("%d%d",&n,&k);
		for(int i=1;i<n;i++)
		{
			int x,y;
			scanf("%d%d",&x,&y);
			link(x,y);
			link(y,x);
		}
		for(int i=1;i<=k;i++)
		{
			int p;
			scanf("%d",&p);
		}
		printf("1\n");
	}
	return 0;
}
