#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
const int N=1e5+5;
int n,k;
long long ans=1;
vector<int>a[N];
int main()
{
	freopen("traverse.in","r",stdin);
	freopen("traverse.out","w",stdout);
	int t;
	cin>>t;
	while(t--)
	{
		
	scanf("%d%d",&n,&k);
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		a[u].push_back(v);
		a[v].push_back(u);
	}
	for(int i=1;i<=k;i++)
	{
		cin>>ans;
	}
	cout<<1<<endl;
	}
	return 0;
}
