#include<bits/stdc++.h>
using namespace std;
const int N=5e5+1;
int n,q;
int main(){
	freopen("traverse.in","r",stdin);
	freopen("traverse.out","w",stdout);
	ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
	int id,t;
	cin>>id>>t;
	while(t--){
		cin>>n>>q;
		for(int i=1;i<n;i++){
			int x,y;
			cin>>x>>y;
		}
		for(int i=1;i<=q;i++){
			int x;
			cin>>x;
		}
		cout<<"1\n";
	}
	return 0;
}
/*
11 10
1 2
1 3
2 4
2 5
2 6
3 7
3 8
5 9
5 10
5 11
*/
