#include<bits/stdc++.h>
using namespace std;
long long mod=1e9+7,n,t,m,v,x[100005],y,las,s,dan,wk;
int main()
{
	freopen("traverse.in","r",stdin);
	freopen("traverse.out","w",stdout);
	cin>>n>>t;
	while(t--)
	{
		cin>>n>>m;
		for(int i=1;i<n;++i)
		cin>>v>>y;
		for(int i=1;i<=m;++i)
		cin>>v;
		cout<<1<<"\n";
	}
	return 0;
}
