#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
int c, T, n, k, E[MAXN];
struct Edge { int u, v; bool w; } e[MAXN];
vector<int> g[MAXN], t[MAXN];
int du[MAXN];
ll fac[MAXN];

void adde(int u, int v, int w) {
	g[u].push_back(v), t[u].push_back(w);
	g[v].push_back(u), t[v].push_back(w);
}

ll qpow(ll x, ll y) {
	ll res = 1;
	for ( ; y; y /= 2, x = x * x % MOD)
		if (y & 1)
			res = res * x % MOD;
	return res;
}
ll inv(ll x) { return qpow(x, MOD - 2); }

namespace Method1 {

const int T = 20;

ll ans;
int dep[MAXN], fa[MAXN][T];
ll val[MAXN][T];

void dfs(int x, int f) {
	dep[x] = dep[f] + 1, fa[x][0] = f, val[x][0] = du[x] * du[x - 1] % MOD * inv(2) % MOD;
	for (int i = 0; i < g[x].size(); i++) {
		int y = g[x][i];
		if (y == f) continue;
		dfs(y, x);
	}
}

int lca(int x, int y) {
	if (dep[x] < dep[y]) swap(x, y);
	for (int t = T - 1; t >= 0; t--)
		if (dep[fa[x][t]] >= dep[y])
			x = fa[x][t];
	for (int t = T - 1; t >= 0; t--)
		if (fa[x][t] != fa[y][t])
			x = fa[x][t], y = fa[y][t];
	if (x != y) x = fa[x][0], y = fa[y][0];
	return x;
}
int dis(int x, int y) {
	return dep[x] + dep[y] - 2 * dep[lca(x, y)];
}
ll qry(int x, int y) {
	int d = lca(x, y);
	ll res = 1;
	for (int t = T - 1; t >= 0; t--)
		if (dep[fa[x][t]] >= dep[d])
			res = res * val[x][t] % MOD, x = fa[x][t];
	for (int t = T - 1; t >= 0; t--)
		if (dep[fa[y][t]] >= dep[d])
			res = res * val[y][t] % MOD, y = fa[y][t];
	return res * val[d][0] % MOD;
}
ll calc(int x) {
	if (du[x] > 1) return inv(du[x]) * 2 % MOD;
	else return 1;
}

void Main() {
	dfs(1, 0);
	for (int t = 1; t < T; t++)
		for (int x = 1; x <= n; x++)
			fa[x][t] = fa[fa[x][t - 1]][t - 1], val[x][t] = val[x][t - 1] * val[fa[x][t - 1]][t - 1] % MOD;
	
	ans = 0;
	for (int i = 1; i <= k; i++)
		ans += calc(e[E[i]].u) * calc(e[E[i]].v) % MOD;
	for (int i = 1; i <= k; i++) {
		for (int j = i + 1; j <= k; j++) {
			int u = e[E[i]].u, v = e[E[i]].v, p = e[E[j]].u, q = e[E[j]].v;
			if (dis(u, p) > dis(v, p)) swap(u, v);
			if (dis(p, u) > dis(q, u)) swap(p, q);
			assert(qry(u, p));
			ans -= calc(v) * calc(q) % MOD * inv(qry(u, p)) % MOD;
			ans = (ans + MOD) % MOD;
		}
	}
	
	for (int i = 1; i <= n; i++) ans = ans * (du[i] == 1 ? 1 : fac[du[i]] * inv(2) % MOD) % MOD;
	printf("%lld\n", ans);
}

} // Method1

int main() {
	freopen("traverse.in", "r", stdin);
	freopen("traverse.out", "w", stdout);
	fac[0] = 1;
	for (int i = 1; i <= 1e5; i++) fac[i] = fac[i - 1] * i;
	scanf("%d%d", &c, &T);
	while (T--) {
		scanf("%d%d", &n, &k);
		for (int i = 1; i < n; i++) scanf("%d%d", &e[i].u, &e[i].v), e[i].w = false;
		for (int i = 1; i <= k; i++) scanf("%d", &E[i]), e[E[i]].w = true;
		for (int i = 1; i <= n; i++) g[i].clear(), t[i].clear();
		for (int i = 1; i < n; i++) adde(e[i].u, e[i].v, e[i].w);
		for (int i = 1; i <= n; i++) du[i] = g[i].size();
//		printf("T = %d\n", T);
		if (k <= 500) Method1::Main();
	}
	return 0;
}

