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

#define ll long long
#define fi first
#define se second
#define pb push_back
#define vi vector<int>
#define mkp make_pair
#define pii pair<int,int>
#define debug(x) cout << #x << " = " << x << "\n";

bool MemoryST;

const int N = 1e5 + 10;
const int mod = 1e9 + 7;

vector<pii> e[N];
int n, k, f[N][2], fac[N], vis[N];

int u[N], v[N];

void init(int n) {
	fac[0] = 1;
	for (int i = 1; i <= n; ++i)
		fac[i] = 1ll * fac[i - 1] * i % mod; 
}

void dfs (int u, int fa) {
	f[u][0] = f[u][1] = 1;
	int s = 0, sz = 0;
	for (auto p : e[u]) {
		int v = p.fi;
		if (v == fa) continue; 
		dfs(v, u);
		if (vis[p.se]) s++; sz++;
		f[u][0] = 1ll * f[u][0] * f[v][0] % mod;
		f[u][1] = 1ll * f[u][1] * (f[v][0] + f[v][1]) % mod;
	}
	if (u == 1) return ;
//	cout << s << "\n";
	f[u][1] = 1ll * f[u][1] * fac[sz] % mod;
	f[u][0] = 1ll * f[u][0] * (sz - s) % mod * fac[sz - 1] % mod;
	f[u][1] = (f[u][1] + mod - f[u][0]) % mod;
//	cout << u << " " << f[u][0] << " " << f[u][1] << "\n";
} 

void Mainsolve() {
	cin >> n >> k;
	for (int i = 1; i < n; ++i) {
		cin >> u[i] >> v[i];
		e[u[i]].pb(mkp(v[i], i));
		e[v[i]].pb(mkp(u[i], i)); 
	}
	int x;
	for (int i = 1; i <= k; ++i) {
		cin >> x; vis[x] = 1;
		
	}
	dfs(u[x], 0);
	int sz = 0, s = 0;
	for (auto p : e[1]) {
		int v = p.fi;
		if (vis[p.se]) ++s; ++sz;
	}
	s = sz - s;
	f[1][1] = 1ll * f[1][1] * fac[sz - 1] % mod;
	if (sz >= 2) {
		f[1][0] = 1ll * f[1][0] * s % mod * (s - 1) % mod * fac[sz - 2] % mod;
		f[1][0] = 1ll * f[1][0] * ((mod + 1) / 2) % mod;
	}
	cout << (f[1][1] + mod - f[1][0]) % mod << "\n";
}

bool MemoryED;

int main() {
	freopen("traverse.in", "r", stdin);
	freopen("traverse.out", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	cerr << fixed << setprecision(6) << (&MemoryST - &MemoryED) / 1024.0 / 1024.0 << "MB\n";

	int c, T = 1; cin >> c >> T; init(N - 5);
	while (T--) Mainsolve();

	cerr << 1e3 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
}
