#include <iostream>
#include <cstdio>
#define MOD 1000000007
#define ll long long

using namespace std;

ll n,k,fac[200001],ans,cnt;

ll qp( ll a , ll b )
{
	ll c = 1;
	while( b )
	{
		if( b & 1 ) c = c * a % MOD;
		b >>= 1;
		a = a * a % MOD;
	}
	return c;
}

int main()
{
	ios::sync_with_stdio( false );
	cin.tie( 0 );
	cout.tie( 0 );
	freopen( "traverse.in" , "r" , stdin );
	freopen( "traverse.out" , "w" , stdout );
	int cid,T,u,v,id;
	cin >> cid >> T;
	fac[0] = 1;
	for( int i = 1 ; i <= 110000 ; i ++ )
		fac[i] = fac[i - 1] * i % MOD;
	while( T -- )
	{
		cin >> n >> k;
		for( int i = 1 ; i < n ; i ++ )
			cin >> u >> v;
		for( int i = 1 ; i <= k ; i ++ )
			cin >> id;
		if( cid == 18 )
		{
			cout << 1 << '\n';
			continue;
		}
		cnt = n - 1 - k;
		ans = fac[n - 1];
		cnt = cnt * ( cnt - 1 ) % MOD * fac[n - 3] % MOD;
		ans = ( ( ans - cnt ) % MOD + MOD ) % MOD;
		cout << ans * qp( 2 , MOD - 2 ) % MOD<< '\n';
	}
	return 0;
}
