#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cassert>
#define ll long long
#define db double
using namespace std;
const int inf=0x3f3f3f3f;
const ll lnf=1e18+10;
const db eps=1e-6;
ll read() {
	ll o=0,w=1;char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1;c=getchar();}
	while(c>='0'&&c<='9') {o=o*10+c-'0';c=getchar();}
	return o*w;
}
namespace dada {

const int N=1e5+10;
const ll P=1e9+7;
int n,m,U[N],V[N];
vector<int> e[N];
int Fa[N],up[N];
ll sumall,dp[N],Ans;
ll fac[N],finv[N];
ll qpow(ll x,ll k) {
	ll ans=1;
	while(k) {
		if(k&1) ans=ans*x%P;
		x=x*x%P;
		k/=2;
	}
	return ans;
}
void dfs1(int x,int fa) {
//	cerr<<x<<"\n";
	Fa[x]=fa;
	for(int v:e[x]) if(v!=fa) dfs1(v,x);
}
void dfs2(int x,int fa) {
	ll sum=0,tmp=(e[x].size()>1? finv[e[x].size()-1]*fac[e[x].size()-2]%P:0);
	for(int v:e[x]) if(v!=fa) {
		dfs2(v,x);
		if(sum) Ans=(Ans-dp[v]*sum%P*tmp%P*sumall%P+P)%P;
		sum=(sum+dp[v])%P;
	}
	if(up[x]) {
		dp[x]=1;
		Ans=(Ans-sum*tmp%P*sumall%P+P)%P;
	} else {
		dp[x]=sum*tmp%P;
	}
}
int Main() {
	n=read(),m=read();
	for(int i=1;i<n;i++) {
		U[i]=read(),V[i]=read();
		e[U[i]].emplace_back(V[i]);
		e[V[i]].emplace_back(U[i]);
	}
	dfs1(1,0);
	// cerr<<"OK1\n";
	for(int id,i=1;i<=m;i++) {
		id=read();
		if(Fa[U[id]]==V[id]) up[U[id]]=1;
		else up[V[id]]=1;
	}
	fac[0]=1;
	for(int i=1;i<=n;i++) fac[i]=fac[i-1]*i%P;
	finv[n]=qpow(fac[n],P-2);
	for(int i=n-1;i>=0;i--) finv[i]=finv[i+1]*(i+1)%P;
	sumall=1;
	for(int i=1;i<=n;i++) sumall=sumall*fac[e[i].size()-1]%P;
	Ans=sumall*m%P;
	// cerr<<sumall<<' '<<Ans<<"\n";
	dfs2(1,0);
	// cerr<<"OK2\n";
	printf("%lld\n",Ans);
	return 0;
}
void clear() {
	for(int i=1;i<=n;i++) {
		U[i]=0,V[i]=0;
		e[i].clear();
		Fa[i]=0,up[i]=0;
		dp[i]=0;
		fac[i]=0,finv[i]=0;
	}
	sumall=0,Ans=0;
}



}
int main() {
	freopen("traverse.in","r",stdin);
	freopen("traverse.out","w",stdout);
	read();
	int T=read();
	while(T--) {
		// cerr<<"Start\n";
		dada::Main();
		dada::clear();
	}
	return 0;
}
/*
cd traverse
g++ traverse.cpp -o traverse -std=c++14 -Wall -O2
time ./traverse
cp traverse1.in traverse.in
diff traverse.out traverse1.ans -w
*/
