#include <bits/extc++.h>
#define dbg(x) cerr << #x" = " << (x) << endl
#define debug(...) fprintf(stderr,__VA_ARGS__)
using ull = unsigned long long;
const int MAXN = 1e5 + 10,MOD = 1e9 + 7;
using namespace std;
int c,n,k,e[MAXN];
struct edge{
	int u,v;
} es[MAXN];
basic_string<int> p[MAXN];


void init0(){
	freopen("traverse.in","r",stdin);
	freopen("traverse.out","w",stdout);
	cin.tie(0) -> ios::sync_with_stdio(0);
}

void init(){
	cin >> n >> k;
	for(int i = 1;i <= n;i++) p[i].clear(),p[i].shrink_to_fit();
	for(int i = 1,u,v;i < n;i++){
		cin >> u >> v;
		p[u] += v,p[v] += u;
		es[i] = {u,v};
	}
	for(int i = 1;i <= k;i++) cin >> e[i];
}

ull dfs(int u,int f){
	if(p[u].size() == 1) {
		// debug("dfs %d %d return %d\n",u,f,1);
		return 1;
	}
	ull res = 0;
	for(int v : p[u]){
		if(v == f) continue;
		res += dfs(v,u);
	}
	// debug("dfs %d %d return %lld\n",u,f,res % MOD);
	return res % MOD;
}

ull dfs0(int u,int f){
	ull res = 0;
	for(int v : p[u]){
		if(v == f) continue;
		res += dfs(v,u);
	}
	// debug("dfs %d %d return %lld\n",u,f,res % MOD);
	return res % MOD;
}

void solve(){
	init();
	cout << (dfs0(es[1].u,es[1].v) + dfs0(es[1].v,es[1].u)) % MOD << '\n';
}

int main(){
	init0();
	int t;
	cin >> c >> t;
	while(t--) solve();
}