#include <bits/stdc++.h>
#define fst first
#define scd second
#define pb emplace_back
#define mkp make_pair
#define uint unsigned
#define mems(a, x) memset((a), (x), sizeof(a))

using namespace std;
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned long long ull;
typedef pair<ll, ll> pii;

inline int read() {
	int x = 0;
	char c = getchar();
	bool f = 0;
	while (c < '0' || c > '9') {
		f |= (c == '-');
		c = getchar();
	}
	while ('0' <= c && c <= '9') {
		x = x * 10 + c - '0';
		c = getchar();
	}
	return f ? -x : x;
}

const int maxn = 200100;
const ll mod = 1000000007;

ll n, m, test, fac[maxn], b[maxn], inv[maxn], deg[maxn], f[maxn], ans;
pii a[maxn];
bool vis[maxn];

int len, hd[maxn], to[maxn << 1], nxt[maxn << 1];

inline void add_edge(int u, int v) {
	to[++len] = v;
	nxt[len] = hd[u];
	hd[u] = len;
}

void dfs(int u, int fa) {
	ll s = 0, w = 0;
	for (int i = hd[u]; i; i = nxt[i]) {
		int v = to[i];
		if (v == fa) {
			continue;
		}
		w = v;
		dfs(v, u);
		f[u] = (f[u] + f[v]) % mod;
		if (u <= n) {
			ans = (ans + f[v] * s % mod * inv[deg[u] - 1]) % mod;
			s = (s + f[v]) % mod;
		}
	}
	if (vis[u]) {
		f[u] = mod - 1;
		ans = (ans - 1 + mod) % mod;
		ans = (ans - f[w] + mod) % mod;
	}
	if (u <= n) {
		f[u] = f[u] * inv[deg[u] - 1] % mod;
	}
}

void solve() {
	n = read();
	m = read();
	fac[0] = 1;
	len = 0;
	for (int i = 1; i <= n * 2; ++i) {
		fac[i] = fac[i - 1] * i % mod;
		f[i] = deg[i] = hd[i] = 0;
		vis[i] = 0;
	}
	inv[1] = 1;
	for (int i = 2; i <= n * 2; ++i) {
		inv[i] = (mod - mod / i) * inv[mod % i] % mod;
	}
	for (int i = 1, u, v; i < n; ++i) {
		u = read();
		v = read();
		a[i] = mkp(u, v);
		add_edge(u, i + n);
		add_edge(i + n, u);
		add_edge(v, i + n);
		add_edge(i + n, v);
		++deg[u];
		++deg[v];
		deg[i + n] = 2;
	}
	for (int i = 1; i <= m; ++i) {
		b[i] = read();
		vis[b[i] + n] = 1;
	}
	ans = 0;
	dfs(1, -1);
	ans = (mod - ans) % mod;
	for (int i = 1; i <= n; ++i) {
		ans = ans * fac[deg[i] - 1] % mod;
	}
	printf("%lld\n", ans);
}

int main() {
	freopen("traverse.in", "r", stdin);
	freopen("traverse.out", "w", stdout);
	test = read();
	int T = read();
	while (T--) {
		solve();
	}
	return 0;
}