#include<bits/stdc++.h>
using namespace std;
int read()
{
	int x=0,w=1;
	char c=0;
	while(c<'0'||c>'9')
	{
		if(c=='-')w=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*w;
}
void solve()
{
	int n,k;
	n=read();k=read();
	for(int i=1;i<n;i++)
	{
		int u,v;u=read();v=read();
	}
	for(int i=1;i<=k;i++)
	{
		int e;e=read();
	}
	printf("1\n");
}
int main()
{
	freopen("traverse.in","r",stdin);
	freopen("traverse.out","w",stdout);
	int c=read(),t=read();
	while(t--)solve();
	return 0;
}

