#include<bits/stdc++.h>
using namespace std;
int T,c;
int main()
{
	freopen("traverse.in","r",stdin);
	freopen("traverse.out","w",stdout);
	scanf("%d%d",&c,&T);
	while(T--)
	{
		int n,k;
		scanf("%d%d",&n,&k);
		for(int i=1;i<n;i++)
		{
			int u,v;
			scanf("%d%d",&u,&v);
		}
		for(int i=1;i<=k;i++)
		{
			int y;
			scanf("%d",&y);
		}
		printf("%d\n",n);
	}
	return 0;
}

