#include <bits/stdc++.h>
#define IL inline
#define LL long long
#define eb emplace_back
#define sz(v) ((int) (v).size())
#define me(f, x) memset(f, x, sizeof(f))
#define mc(f, g) memcpy(f, g, sizeof(f))
#define L(i, j, k) for (int i = (j); i <= (k); ++i)
#define R(i, j, k) for (int i = (j); i >= (k); --i)
#define FIO(FILE) freopen(FILE".in", "r", stdin), freopen(FILE".out", "w", stdout)
using namespace std;

using vi = vector<int>;

namespace IO {
  char buf[1 << 21], *iS, *iT;

#define gh() (iS == iT ? iT = (iS = buf) + fread(buf, 1, 1 << 21, stdin), (iS == iT ? EOF : *iS++) : *iS++)

  IL int rd () {
    int x = 0;
    char c = gh();
    while (c < '0' || c > '9') {
      c = gh();
    }
    while ('0' <= c && c <= '9') {
      x = x * 10 + (c ^ 48);
      c = gh();
    }
    return x;
  }
}

using IO::rd;

constexpr int N = 2e5 + 9;
constexpr int P = 1e9 + 7;
int op, n, k, all, ans, a[N], fc[N], ifc[N], iv[N];
vi g[N];

IL int qpow (int b, int k = P - 2) {
  int s = 1;
  for (; k; k >>= 1, b = (LL)b * b % P) if (k & 1) s = (LL)s * b % P;
  return s;
}

void init (int Z) {
  fc[0] = 1;
  L (i, 1, Z) {
    fc[i] = (LL)fc[i - 1] * i % P;
  }
  ifc[Z] = qpow(fc[Z]);
  R (i, Z - 1, 0) {
    ifc[i] = (LL)ifc[i + 1] * (i + 1) % P;
  }
  L (i, 1, Z) {
    iv[i] = (LL)ifc[i] * fc[i - 1] % P;
  }
}

IL int C (int n, int m) {
  return n < m || m < 0 ? 0 : (LL)fc[n] * ifc[m] % P * ifc[n - m] % P;
}

IL void add_edge (int u, int v) {
  g[u].eb(v);
  g[v].eb(u);
}

IL void qm (int &x) {
  x += (x >> 31) & P;
}

int dp[N];

void dfs (int u, int f) {
  for (int v : g[u]) {
    if (v ^ f) {
      dfs(v, u);
      qm(dp[u] += dp[v] - P);
    }
  }
  if (a[u]) {
    ans = (ans + (LL)(P - dp[u]) * all) % P;
    dp[u] = 1;
  } else {
    int x = 0, y = 0;
    for (int v : g[u]) {
      if (v ^ f) {
        x = (x + (LL)dp[v] * y) % P;
        qm(y += dp[v] - P);
      }
    }
    if (u <= n) {
      x = (LL)x * iv[sz(g[u]) - 1] % P;
      dp[u] = (LL)dp[u] * iv[sz(g[u]) - 1] % P;
    }
    ans = (ans + (LL)(P - x) * all) % P;
  }
}

void slv () {
  n = rd(), k = rd();
  L (i, 1, n - 1) {
    int u = rd(), v = rd();
    add_edge(i + n, u);
    add_edge(i + n, v);
  }
  L (i, 1, k) {
    int x = rd();
    a[x + n] += 1;
  }
  all = 1;
  L (i, 1, n) {
    all = (LL)all * fc[sz(g[i]) - 1] % P;
  }
  ans = (LL)k * all % P;
  dfs(1, 0);
  cout << ans << '\n';
  L (i, 1, 2 * n - 1) {
    a[i] = 0;
    dp[i] = 0;
    g[i].clear();
  }
}

int main () {
  FIO("traverse");
  ios::sync_with_stdio(0), cin.tie(0);
  init(N - 3);
  op = rd();
  int T = rd();
  while (T--) {
    slv();
  }
  cerr << clock() << '\n';
}
// I love WHQ!