#include<iostream>
using namespace std;
const int N=1e5+5;

inline int read()
{
	int s=0;
	char c=getchar();
	while(c<'0'||c>'9')c=getchar();
	while(c>='0'&&c<='9')s=s*10+c-'0',c=getchar();
	return s;
}

int u[N],v[N],e[N];

int main()
{
	freopen("traverse.in","r",stdin);
	freopen("traverse.out","w",stdout);
	int c=read(),T=read();
	while(T--)
	{
		int n=read(),k=read();
		for(int i=1;i<n;i++)
		{
			u[i]=read();
			v[i]=read();
		}
		for(int i=1;i<=k;i++)
		{
			e[i]=read();
		}
		cout<<1<<'\n';
	}
	return 0;
}
