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

struct R {
	int u, v, lst;
}road[N<<1];

int c, t, n, k, id, final[N], e[N];

void add (int tu, int tv) {
	road[++id].u = tu;
	road[id].v = tv;
	road[id].lst = final[tu];
	final[tu] = id;
}

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++) {
			int u, v;
			scanf("%d%d", &u, &v);
			add(u, v);
			add(v, u);
		}
		
		for (int i = 1;i <= k;i++) scanf("%d", e[i]);
		printf("%d\n", 4);
	}
	return 0;
}
