#include<cstdio>
#include<cstring>
#include<vector>
#define N 100010
#define ll long long
#define mod 1000000007
using namespace std;
int n, k, c[N], d[N];
ll mul[N], f[N], ans, inv[N], yu;
struct edge
{
	int to, id;
};
vector<edge>e[N];
void dfs(int now, int fa, int id)
{
//	printf("%d %d %d %d\n", now, fa, id, de);
	f[now] = 0;
	for(int i = 0; i < e[now].size(); i++)
	{
		edge to = e[now][i];
		if(to.to != fa)
		{
			dfs(to.to, now, to.id);
			ans = (ans - yu * f[now] % mod * f[to.to] % mod + mod) % mod;
			f[now] = (f[now] + f[to.to] * inv[d[now] - 1]) % mod;
		}
	}
	if(c[id])
	{
		ans = (ans - yu * f[now] % mod + mod) % mod;
		f[now] = 1;
	}
}
void slove()
{
	scanf("%d%d", &n, &k);
	memset(c, 0, sizeof c);
	memset(d, 0, sizeof d);
	for(int i = 1; i <= n; i++)e[i].clear();
	mul[0] = 1;
	inv[0] = inv[1] = 1;
	for(int i = 2; i <= n; i++)inv[i] = inv[mod % i] * (mod - mod / i) % mod;
	for(int i = 1; i <= n; i++)mul[i] = mul[i - 1] * i % mod;
	for(int i = 1; i < n; i++)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		e[u].push_back((edge){v, i});
		e[v].push_back((edge){u, i});
		d[u]++;
		d[v]++;
	}
	for(int i = 1; i <= k; i++)
	{
		int e;
		scanf("%d", &e);
		c[e] = 1;
	}
	ans = k;
	for(int i = 1; i <= n; i++)ans = ans * mul[d[i] - 1] % mod;
	yu = ans * inv[k] % mod;
	dfs(1, 0, 0);
	printf("%lld\n", ans);
}
int main()
{
	freopen("traverse.in", "r", stdin);
	freopen("traverse.out", "w", stdout);
	int t, id;
	scanf("%d%d", &id, &t);
	while(t--)slove();
	return 0;
}
