#include <bits/stdc++.h>
using namespace std;
int C,T,n,k;
signed main(){
	freopen("traverse.in","r",stdin);
	freopen("traverse.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>C>>T;
	while(T--){
		cin>>n>>k;
		for(int i=1;i<n;i++){
			int aa,bb;
			cin>>aa>>bb;
		}
		for(int i=1;i<=k;i++){
			int aa;
			cin>>aa;
		}
		cout<<1<<'\n';
	}
	return 0;
}
/*

*/
