#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int MAX_N = 1e5 + 5;

int c, t;

struct AdjList {
	int tot, head[MAX_N], nxt[MAX_N << 1], to[MAX_N << 1];
	
	void init() {
		tot = 1;
		memset(head, -1, sizeof(head));
	}
	
	void insert(int x, int y) {
		to[++tot] = y;
		nxt[tot] = head[x];
		head[x] = tot;
	}
} tree;

int main() {
	freopen("traverse1.in", "r", stdin);
//	freopen("traverse.out", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(nullptr);
	cin >> c >> t;
	while (t--) {
		int n, k;
		cin >> n >> k;
		tree.init();
		for (int i = 1; i < n; ++i) {
			int u, v;
			cin >> u >> v;
			tree.insert(u, v); tree.insert(v, u);
		}
		for (int i = 1; i <= k; ++i) {
			int e; cin >> e;
		}
		cout << k << '\n';
	}
	cout.flush();
	fclose(stdin);
//	fclose(stdout);
	return 0;
}
