#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
static char buf[1000000],*p1=buf,*p2=buf;
#define GC()	(p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++)
int read(){
	int x = 0; char c = GC();
	while(c < '0' || c > '9') c = GC();
	while(c >= '0' && c <= '9'){
		x = (x << 3) + (x << 1) + c - '0'; c = GC();
	}
	return x;
}
const int mod = 1e9+7;
int Sub, n, k, ans, hd[100010], e[200010][2], deg[100010];
int fac[100010], inv[100010], f[100010];
bool bk[100010];
void add(int &x,int y){x+=y;if(x>=mod)x-=mod;}
void dfs(int u, int fa){
	f[u] = 0;
	int i, v, x = inv[deg[u] - 1];
	for(i = hd[u]; i > 0; i = e[i][0]){
		v = e[i][1];
		if(v != fa){
			dfs(v, u);
			add(ans, mod - (ll)f[u] * f[v] % mod);
			f[u] = (f[u] + (ll)f[v] * x) % mod;
		}
	}
	for(i = hd[u]; i > 0; i = e[i][0]){
		v = e[i][1];
		if(v == fa){
			if(bk[i >> 1]){
				add(ans, mod - f[u]);
				f[u] = 1;
			}
			break;
		}
	}
}
void solve(){
	int i, u, v;
	n = read(); k = read(); ans = k;
	for(i = 1; i <= n; i++) hd[i] = deg[i] = 0, bk[i] = false;
	for(i = 1, fac[0] = 1; i <= n; i++) fac[i] = (ll)fac[i - 1] * i % mod;
	for(i = 2, inv[0] = 0, inv[1] = 1; i <= n; i++) inv[i] = (ll)(mod - mod / i) * inv[mod % i] % mod;
	for(i = 2; i >> 1 < n; i++){
		u = read(); v = read(); deg[u]++; deg[v]++;
		e[i][0] = hd[u]; e[i][1] = v; hd[u] = i;
		i++;
		e[i][0] = hd[v]; e[i][1] = u; hd[v] = i;
	}
	for(i = 1; i <= k; i++){
		bk[read()] = true;
	}
	dfs(1, 0);
	for(i = 1; i <= n; i++) ans = (ll)ans * fac[deg[i] - 1] % mod;
	printf("%d\n", ans);
}
int main()
{
	freopen("traverse.in", "r", stdin);
	freopen("traverse.out", "w", stdout);
	Sub = read();
	int t = read();
	while(t--) solve();
	return 0;
}
