#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;

int c,T;
int n,k;
vector<int> e[N];
int g[N];
int main(){
//	ios::sync_with_stdio(0);
//	cin.tie(0);
	freopen("traverse.in","r",stdin);
	freopen("traverse.out","w",stdout);
	cin >> c >> T;
	while(T--){
		cin >> n >> k;
		for(int i = 1;i < n;i++){
			int u,v;
			cin >> u >> v;
			e[u].push_back(v);
			
		}
		for(int i = 1;i <= k;i++){
			cin >> g[i];
		}
		cout << 2 << endl;
		
	}
	return 0; 
}
