#include<bits/stdc++.h>
using namespace std;
const int N=101010;
int T,n,m,u[N],v[N],x[N],id,k,a[1010][1010],ans,vis[N];
vector<int>G[N];
vector<int>e[N];
int read(){
	int sum=0;
	char ch;
	ch=getchar();
	while(ch>='0'&&ch<='9'){
		sum=sum*10+(ch-'0');
		ch=getchar();
	}
	return sum;
}
int main(){
	freopen("traverse.in","r",stdin);
	freopen("traverse.out","w",stdout);
	id=read(),T=read(); 
	while(T--){
		ans=0;
		n=read(),k=read();
		for(int i=1;i<n;i++){
			u[i]=read(),v[i]=read();
			if(id==18)continue;
		}
		for(int i=1;i<=k;i++)x[i]=read();
		if(id==18){
			printf("1\n");
			continue;
		}
	}
	return 0;
}
