#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+3;
const ll mod=1e9+7;
ll ji[N];
int n,k,T,c;
int main(){
	freopen("traverse.in","r",stdin);
	freopen("tarverse.out","w",stdout);
	ji[0]=1;for(int i=1;i<=100000;i++) ji[i]=ji[i-1]*i%mod;
	scanf("%d%d",&c,&T);
	while(T--){
		scanf("%d%d",&n,&k);
		for(int i=1,u,v;i<n;i++){
			scanf("%d%d",&u,&v);
		}
		for(int i=1,x;i<=k;i++) scanf("%d",&x);
		if(c==18) puts("1");
		else puts("2");
	}
	return 0;
}

