#include<bits/stdc++.h>
using namespace std;
int main()
{
	freopen("traverse.in","r",stdin);
	freopen("traverse.out","w",stdout);
	int a,b,c;
	cin>>a>>b;
	while(b--)
	{
		int n,k;
		cin>>n>>k;
		for(int i=1;i<=n-1;i++)
		cin>>c>>c;
		for(int i=1;i<=k;i++)
		cin>>c;
		cout<<2<<endl;
	}
	return 0;
}
