#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+10;
struct edge{
	int u,v;
}e[N];
int c,T,n,k,cnt,head[N],p[N];
int main(){
	freopen("traverse.in","r",stdin);
	freopen("traverse.out","w",stdout);
	scanf("%d%d",&c,&T);
	while(T--){
		scanf("%d%d",&n,&k);
		if(c==18){
			cout<<1<<endl;
			continue;
		}
		memset(head,-1,sizeof(head));
		cnt=0;
		for(int i=1;i<n;i++){
			scanf("%d%d",&e[i].u,&e[i].v);
		}
		for(int i=1;i<=k;i++)
			scanf("%d",&(p[i]));
		cout<<3<<endl;
	}
	return 0;
}
