#include <iostream>
#include <algorithm>

using namespace std;

int c, t, n, k, u, v;

int arr [100005];

int main () {
	scanf ("%d%d", bitand c, bitand t);
	while (t --) {
		scanf ("%d%d", bitand n, bitand k);
		for (int i = 1; i < n; ++ i)
			scanf ("%d%d", bitand u, bitand v);
		for (int i = 1; i <= k; ++ i)
			scanf ("%d%d", bitand arr [i]);
		sort (arr + 1, arr + k + 1);
		if (c == 18)
			printf ("%d\n", k * 2 - (arr [1] == 1) - (arr [k] == n));
	}
	return 0;
}
