#include <bits/stdc++.h>

#ifdef XSLOCAL
#define XS_DEBUG_MODE
#endif

#ifndef XS_DEBUG_MODE
#define dblog(str, args...)
#else
#define dblog(str, args...) (fprintf(stderr, str, ##args))
#endif

namespace xiaosuan {

using std::bitset;

using sll = long long;

const int MAX_N = int(1e5);
const int MAX_K = MAX_N - 1;
const int MOD = int(1e9) + 7;

#define sfop(x, y, op) ((sll(x) op sll(y)) % MOD)
#define sfad(x, y) sfop(x, y, +)
#define sfsb(x, y) sfad(x, MOD - y)
#define sfml(x, y) sfop(x, y, *)

int n, k;

bitset <MAX_N * 2 + 10> B;

int F[MAX_N + 10];

int to[MAX_N * 2 + 10];
int nxt[MAX_N * 2 + 10];
int dp1[MAX_N * 2 + 10];

int dp2[MAX_N * 2 + 10];
int H[MAX_N + 10];

int C[MAX_N + 10];

int qpow(int a, int b) {
	int c = 1;
	while (b) {
		if (b & 1) c = sfml(c, a);
		b >>= 1;
		a = sfml(a, a);
	}
	return c;
}

int inv(int a) {
	return qpow(a, MOD - 2);
}

void mkedge(int u, int v, int e) {
	to[e] = v;
	nxt[e] = H[u];
	H[u] = e;
	++C[u];
}

void dfs1(int eu) {
	int u = to[eu];
	dp1[eu] = 1;
	for (int ev = H[u]; ev != -1; ev = nxt[ev]) {
		if ((ev ^ eu) == 1) continue;
		dfs1(ev);
		dp1[eu] = sfml(dp1[eu], dp1[ev]);
	}
	dp1[eu] = sfml(dp1[eu], F[C[u] - 1]);
}

void dfs2(int eu) {
	int u = to[eu];
	for (int ev = H[u]; ev != -1; ev = nxt[ev]) {
		if ((ev ^ eu) == 1) continue;
		dp1[ev ^ 1] = sfml(dp1[eu], sfml(inv(dp1[ev]), dp1[eu ^ 1]));
		dfs2(ev);
	}
}

int ans;

void dfs3(int eu) {
	int u = to[eu];
	dp2[eu] = 0;
	int sa = 0;
	int sb = 0;
	for (int ev = H[u]; ev != -1; ev = nxt[ev]) {
		if ((ev ^ eu) == 1) continue;
		dfs3(ev);
		sa = sfad(sa, dp2[ev]);
		sb = sfsb(sb, sfml(dp2[ev], dp2[ev]));
	}
	sb = sfad(sb, sfml(sa, sa));
	sb = sfml(sb, inv(2));
	ans = sfsb(ans, sfml(sb, F[C[u] - 2]));
	if (B[eu]) {
		dp2[eu] = dp1[eu];
		ans = sfad(ans, sfml(dp1[eu], dp1[eu ^ 1]));
		ans = sfsb(ans, sfml(sa, sfml(F[C[u] - 2], dp1[eu ^ 1])));
	} else {
		dp2[eu] = sfml(sa, F[C[u] - 2]);
	}
}

int main() {
	freopen("traverse.in", "r", stdin);
	freopen("traverse.out", "w", stdout);
	F[0] = 1;
	for (int i = 1; i < MAX_N + 10; ++i) {
		F[i] = sfml(F[i - 1], i);
		C[i] = 0;
	}
	int T;
	scanf("%*d%d", &T);
	while (T--) {
		scanf("%d%d", &n, &k);
		for (int i = 0; i <= n; ++i) {
			H[i] = -1;
		}
		for (int i = 0; i < n; ++i) {
			B[i * 2] = B[i * 2 + 1] = 0;
		}
		for (int i = 1; i < n; ++i) {
			int u, v;
			scanf("%d%d", &u, &v);
			mkedge(u, v, i * 2);
			mkedge(v, u, i * 2 + 1);
		}
		for (int i = 0; i < k; ++i) {
			int e;
			scanf("%d", &e);
			B[e * 2] = B[e * 2 + 1] = 1;
		}
		if (n == 1) {
			puts("1");
			continue;
		}
		dfs1(2);
		dfs1(3);
		dfs2(2);
		dfs2(3);
		ans = 0;
		dfs3(2);
		dfs3(3);
		ans = sfsb(ans, sfml(dp2[2], dp2[3]));
//		dblog("%d %d %d %d\n", dp1[2], dp1[3], dp2[2], dp2[3]);
		printf("%d\n", ans);
	}
	return 0;
}

}

int main() {
	return xiaosuan::main();
}
