#include<bits/stdc++.h>
using namespace std;
int T, n, m, i, j, k, x, y, a[100050];
int main() {
	freopen("traverse.in", "r", stdin);
	freopen("traverse.out", "w", stdout);
	scanf("%*d%d", &T);
	while (T--) {
		scanf("%d%d", &n, &m);
		for (i=1; i<n; i++) {
			scanf("%d%d", &x, &y);
		}
		for (i=1; i<=m; i++) {
			scanf("%d", &x);
		}
		printf("1\n");
	}
	return 0;
}
