#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 1) + (x << 3) + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const long long maxn = 2e5 + 1e2;
const long long maxm = 2 * maxn;
const long long mod = 1e9 + 7;
long long dp[310];
long long a[maxn];
long long deep[maxn];
long long num[maxn];
long long n, m;
long long f[maxn][21];
long long cnt;
long long q, tot;
long long root;
long long dfn[maxn];
long long ymh[maxn], b[maxn];
long long tmp = 0, k;
long long nxt[maxm], to[maxm], point[maxm];
void addedge(long long x, long long y) {
  nxt[++cnt] = point[x];
  to[cnt] = y;
  point[x] = cnt;
}
void insert(long long x, long long y) {
  addedge(x, y);
  addedge(y, x);
}
void dfs(long long x, long long fa, long long dep) {
  dfn[x] = ++tot;
  deep[x] = dep;
  for (long long i = point[x]; i; i = nxt[i]) {
    long long p = to[i];
    if (p == fa) continue;
    f[p][0] = x;
    dfs(p, x, dep + 1);
  }
}
void init() {
  for (long long j = 1; j <= 20; j++) {
    for (long long i = 1; i <= n; i++) {
      f[i][j] = f[f[i][j - 1]][j - 1];
    }
  }
}
long long s[maxn], top;
long long tag[maxn];
long long go_up(long long x, long long d) {
  for (long long i = 0; i <= 20; i++)
    if (d & (1 << i)) x = f[x][i];
  return x;
}
long long lca(long long x, long long y) {
  if (deep[x] > deep[y])
    x = go_up(x, deep[x] - deep[y]);
  else
    y = go_up(y, deep[y] - deep[x]);
  if (x == y) return x;
  for (long long i = 20; i >= 0; i--) {
    if (f[x][i] != f[y][i]) {
      x = f[x][i];
      y = f[y][i];
    }
  }
  return f[x][0];
}
bool cmp(long long a, long long b) { return dfn[a] < dfn[b]; }
long long qq;
void dfs1(long long x, long long fa, long long val, long long flag) {
  if (tag[x] == flag) {
    b[++tmp] = x;
    num[tmp] = val;
  }
  for (long long &i = point[x]; i; i = nxt[i]) {
    long long p = to[i];
    if (p == fa) continue;
    dfs1(p, x, val + (tag[x] == flag), flag);
  }
}
long long solve1(long long flag) {
  dfs1(root, 0, 0, flag);
  dp[0] = 1;
  for (long long i = 1; i <= tmp; i++) {
    for (long long j = m; j >= 0; j--)
      if (j > num[i])
        dp[j] = (dp[j - 1] + 1ll * dp[j] * 1ll * (j - num[i]) % mod) % mod;
      else
        dp[j] = 0;
  }
  long long ans = 0;
  for (long long i = 0; i <= m; i++) ans = (ans + dp[i]) % mod;
  return ans;
}
long long solve(long long flag) {
  memset(dp, 0, sizeof(dp));
  tmp = 0;
  cnt = 0;
  for (long long i = 1; i <= k; i++) tag[a[i]] = flag;
  a[++k] = root;
  sort(a + 1, a + 1 + k, cmp);
  long long ptx = a[1];
  for (long long i = 2; i <= k; i++) ptx = lca(a[i], ptx);
  top = 1;
  s[top] = ptx;
  for (long long i = 1; i <= k; i++) {
    long long l = lca(a[i], s[top]);
    if (s[top] != l) {
      while (top > 1) {
        if (dfn[s[top - 1]] > dfn[l]) {
          insert(s[top - 1], s[top]);
          top--;
        } else {
          if (dfn[s[top - 1]] == dfn[l]) {
            insert(s[top - 1], s[top]);
            top--;
            break;
          } else {
            insert(l, s[top]);
            s[top] = l;
            break;
          }
        }
      }
    }
    if (s[top] != a[i]) s[++top] = a[i];
  }
  while (top > 1) {
    insert(s[top - 1], s[top]);
    top--;
  }
  return solve1(flag);
}
signed main() {
  n = read(), q = read();
  for (long long i = 1; i < n; i++) {
    long long x = read(), y = read();
    insert(x, y);
  }
  dfs(1, 0, 1);
  init();
  cnt = 0;
  memset(point, 0, sizeof(point));
  for (long long i = 1; i <= q; i++) {
    ++qq;
    k = read(), m = read(), root = read();
    for (long long j = 1; j <= k; j++) a[j] = read();
    cout << solve(qq) << "\n";
  }
  return 0;
}
