#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int MAXN=1e5+5;
const int MOD=1e9+7;
int n,k;ll fac[MAXN],inv[MAXN],ans,coef,s,sum;bool ok;
int eu[MAXN],ev[MAXN];bool flag[MAXN],vis[MAXN];
int siz[MAXN],msiz[MAXN],tsiz,mson,d[MAXN];
int lst[MAXN],nxt[MAXN<<1],to[MAXN<<1],tot;bool typ[MAXN<<1];
ll ksm(ll a,int b){ll r=1;while(b){if(b&1)r=r*a%MOD;a=a*a%MOD,b>>=1;}return r;} 
void add(int u,int v,bool t){
	++tot;
	nxt[tot]=lst[u];to[tot]=v;typ[tot]=t;lst[u]=tot;
}
void get_size(int u,int fa){
	siz[u]=msiz[u]=1;
	for(int e=lst[u];e;e=nxt[e]) if(!vis[to[e]]&&to[e]!=fa){
		get_size(to[e],u);
		siz[u]+=siz[to[e]];
		msiz[u]=max(msiz[u],siz[to[e]]);
	}
	msiz[u]=max(msiz[u],tsiz-siz[u]);
	if(msiz[u]<msiz[mson]) mson=u;
}
void dfs(int u,int fa,ll c){
	c=c*inv[d[u]-1]%MOD;
	for(int e=lst[u];e;e=nxt[e]) if(to[e]!=fa){
		if(typ[e]) s+=c,ok=true;
		else if(!vis[to[e]]) dfs(to[e],u,c);
	}
} 
void dfz(int rt){
	vis[rt]=true;
	s=sum=0;
	for(int e=lst[rt];e;e=nxt[e]){
		if(typ[e]) coef-=sum,sum=(sum+inv[d[rt]-1])%MOD;
		else if(!vis[to[e]]){
			s=0;ok=false;
			dfs(to[e],rt,1);s%=MOD;
			coef-=sum*s%MOD,sum=(sum+inv[d[rt]-1]*s)%MOD;
			if(!ok) vis[to[e]]=true;
		}
	}
	for(int e=lst[rt];e;e=nxt[e]) if(!vis[to[e]]){
		tsiz=siz[to[e]];mson=0;
		get_size(to[e],0);get_size(mson,0);dfz(mson);
	}
}
void solve(){
	cin>>n>>k;
	memset(flag,0,sizeof(flag));memset(vis,0,sizeof(vis));
	memset(lst,0,sizeof(lst));memset(d,0,sizeof(d));tot=0;
	for(int i=1;i<n;i++){
		cin>>eu[i]>>ev[i];
		d[eu[i]]++;d[ev[i]]++;
	}
	for(int i=1;i<=k;i++){
		int x;cin>>x;flag[x]=true;
	}
	for(int i=1;i<n;i++){
		add(eu[i],ev[i],flag[i]);
		add(ev[i],eu[i],flag[i]);
	}
	ans=1,coef=k;
	for(int i=1;i<=n;i++) ans=ans*fac[d[i]-1]%MOD;
	msiz[0]=1e9;mson=0;tsiz=n;
	get_size(1,0);get_size(mson,0);dfz(mson);
	coef=(coef%MOD+MOD)%MOD;
	cout<<ans*coef%MOD<<'\n';
}
int main(){
	ios::sync_with_stdio(false);
	freopen("traverse.in","r",stdin);
	freopen("traverse.out","w",stdout);
	fac[0]=1;
	for(int i=1;i<MAXN;i++) fac[i]=fac[i-1]*i%MOD,inv[i]=ksm(i,MOD-2);
	int c,T;cin>>c>>T;
	while(T--) solve();
}
// test small data
// compile in NOI Linux2

