#include<iostream>
using namespace std;
const int N=100005;
int c,T,n,k,x,y;
int read(){
	int ans=0;
	char ch=getchar();
	while(!(ch>='0'&&ch<='9'))ch=getchar();
	ans=ch-'0';
	while(ch>='0'&&ch<='9'){
		ch=getchar();
		ans=ans*10+ch-'0';
	}
	return ans;
}
int main(){
	freopen("traverse.in","r",stdin);
	freopen("traverse.out","w",stdout);
	scanf("%d %d",&c,&T);
	while(T--){
		scanf("%d %d",&n,&k);
		for(int i=1;i<n;i++){
			x=read();y=read();
		}
		for(int i=1;i<=k;i++)x=read();
		printf("1\n");
	}
	return 0;
}
