#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define debug(...) fprintf(stderr, ##__VA_ARGS__)
#else
#define debug(...) void(0)
#define endl "\n"
#endif
using LL = long long;
template <unsigned umod>
struct modint {/*{{{*/
  static constexpr int mod = umod;
  unsigned v;
  modint() = default;
  template <class T, enable_if_t<is_integral<T>::value>* = nullptr> modint(const T& _y):
    v((unsigned)(_y % mod + (is_signed<T>() && _y < 0 ? mod : 0))) {}
  modint& operator+=(const modint& rhs) { v += rhs.v; if (v >= umod) v -= umod; return *this; }
  modint& operator-=(const modint& rhs) { v -= rhs.v; if (v >= umod) v += umod; return *this; }
  modint& operator*=(const modint& rhs) { v = (unsigned)(1ull * v * rhs.v % umod); return *this; }
  modint& operator/=(const modint& rhs) { assert(rhs.v); return *this *= qpow(rhs, mod - 2); }
  template <class T, enable_if_t<is_integral<T>::value>* = nullptr> friend modint qpow(modint a, T b) {
    modint r = 1;
    while (b) {
      if (b & 1) r *= a;
      if (b >>= 1) a *= a;
    }
    return r;
  }
  friend int raw(modint self) { return self.v; }
  friend ostream& operator<<(ostream& os, modint self) { return os << raw(self); }
  friend modint operator+(modint lhs, const modint& rhs) { return lhs += rhs; }
  friend modint operator-(modint lhs, const modint& rhs) { return lhs -= rhs; }
  friend modint operator*(modint lhs, const modint& rhs) { return lhs *= rhs; }
  friend modint operator/(modint lhs, const modint& rhs) { return lhs /= rhs; }
  explicit operator bool() const { return v != 0; }
};/*}}}*/
using mint = modint<int(1e9 + 7)>;
constexpr int N = 1e5 + 10;
int sub, n, m, siz[N], smx[N], ctt[N];
bool vis[N];
mint fac[N], ans, ans0, inv[N];
bool key[N];
vector<pair<int, int>> g[N];
pair<int, int> edges[N];
mint dfs(int u, int fa) {
  vis[u] = true;
  mint w = inv[(int)g[u].size() - 1];
  mint sum = ctt[u] * w;
  for (auto e : g[u]) {
    int v = e.first, id = e.second;
    if (v == fa || key[id]) continue;
    mint res = dfs(v, u);
    ans -= sum * res;
    sum += res * w;
  }
  return sum;
}
int mian() {
  cin >> n >> m;
  fac[0] = inv[1] = 1;
  for (int i = 1; i <= n; i++) fac[i] = fac[i - 1] * i;
  for (int i = 2; i <= max(n, 2); i++) inv[i] = -mint::mod / i * inv[mint::mod % i];
  for (int i = 1; i <= n; i++) g[i].clear(), key[i] = false, vis[i] = false, ctt[i] = 0;
  for (int i = 1, u, v; i < n; i++) cin >> u >> v, g[u].emplace_back(v, i), g[v].emplace_back(u, i), edges[i] = {u, v};
  for (int i = 1, e; i <= m; i++) cin >> e, key[e] = true;
  ans0 = 1;
  for (int i = 1; i <= n; i++) ans0 *= fac[(int)g[i].size() - 1];
  ans = m;
  for (int i = 1; i < n; i++) if (key[i]) {
    int u, v;
    tie(u, v) = edges[i];
    ctt[u] += 1, ctt[v] += 1;
  }
  for (int i = 1; i <= n; i++) if (ctt[i] >= 2) ans -= mint(ctt[i]) * (ctt[i] - 1) * inv[2] * inv[(int)g[i].size() - 1];
  for (int i = 1; i <= n; i++) if (!vis[i]) dfs(i, 0);
  cout << ans0 * ans << endl;
  return 0;
}
int main() {
#ifndef LOCAL
#ifndef NF
  freopen("traverse.in", "r", stdin);
  freopen("traverse.out", "w", stdout);
#endif
  cin.tie(nullptr)->sync_with_stdio(false);
#endif
  int t;
  cin >> sub >> t;
  while (t--) mian();
  return 0;
}

