#include <bits/stdc++.h>
const int P = 1000000007;
using namespace std;
template <class T>
using vector2D = vector<vector<T>>;
template <class T>
using vector3D = vector<vector2D<T>>;
template <class T>
bool umax(T &x, T y) {
  return (x < y) ? x = y, true : false;
}
template <class T>
bool umin(T &x, T y) {
  return (x > y) ? x = y, true : false;
}
void prepare() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
struct VTREE {
  struct ST {
    int n, m;
    vector<int> key;
    vector2D<int> st;
    int lg(int x) { return 31 - __builtin_clz(x); }
    int merge(int x, int y) { return (key[x] < key[y]) ? x : y; }
    void init(vector<int> &a, vector<int> &key_) {
      n = ((int)(a).size());
      m = lg(n - 1) + 1;
      key = key_;
      st.resize(m);
      st[0] = a;
      for (int i = (1); i < (m); i++) st[i].resize(n - (1 << i) + 1);
      for (int i = (1); i < (m); i++)
        for (int j = 0; j < (((int)(st[i]).size())); j++)
          st[i][j] = merge(st[i - 1][j], st[i - 1][j + (1 << (i - 1))]);
    }
    int calc(int l, int r) {
      int k = lg(r - l);
      return merge(st[k][l], st[k][r - (1 << k)]);
    }
  } st;
  struct edge {
    int to;
    long long c;
  };
  int n, root;
  vector<long long> len;
  vector<vector<edge>> go;
  vector<int> fa, sz, dep, lno, rno, pos;
  vector<int> piv, vis;
  void init(int n_, int root_) {
    n = n_;
    root = root_;
    pos.clear();
    fa.assign(n, -1);
    sz.assign(n, 1);
    go.assign(n, {});
    dep.assign(n, 0);
    len.assign(n, 0);
    lno.assign(n, -1);
    rno.assign(n, -1);
    piv.assign(n, 0);
    vis.assign(n, 0);
  }
  void read() {
    int u, v;
    for (int i = 0; i < (n - 1); i++) cin >> u >> v, add(u - 1, v - 1);
  }
  void add(int u, int v, long long w = 1) {
    go[u].push_back({v, w});
    go[v].push_back({u, w});
  }
  void _dfs(int x) {
    lno[x] = ((int)(pos).size());
    pos.push_back(x);
    for (auto &e : go[x])
      if (e.to != fa[x]) {
        dep[e.to] = dep[x] + 1;
        len[e.to] = len[x] + e.c;
        fa[e.to] = x;
        _dfs(e.to);
        sz[x] += sz[e.to];
        pos.push_back(x);
      }
    rno[x] = ((int)(pos).size());
  }
  int lca(int x, int y) {
    x = lno[x];
    y = lno[y];
    if (x > y) swap(x, y);
    return st.calc(x, y + 1);
  }
  long long dist(int x, int y) { return len[x] + len[y] - 2 * len[lca(x, y)]; }
  void build() {
    _dfs(root);
    ;
    st.init(pos, dep);
    for (int i = 0; i < (n); i++) go[i].clear();
  }
  int M, R;
  vector<long long> ans;
  void dfs(int x, int fr, int pre) {
    ;
    if (piv[x]) {
      ++pre;
      umin(pre, M + 1);
      for (int i = (M + 1) - 1; i >= (pre); i--)
        ans[i] = (ans[i - 1] + ans[i] * (i - pre + 1)) % P;
      for (int i = 0; i < (pre); i++) ans[i] = 0;
    }
    for (auto e : go[x])
      if (e.to != fr) dfs(e.to, x, pre);
  }
  void solve(vector<int> a, int m, int r) {
    ;
    M = m;
    R = r;
    ans.assign(M + 1, 0);
    ans[0] = 1;
    auto cmp = [&](int x, int y) { return lno[x] < lno[y]; };
    for (auto x : a) vis[x] = piv[x] = 1;
    if (!vis[r]) a.push_back(r), vis[r] = 1;
    sort((a).begin(), (a).end(), cmp);
    for (int i = (((int)(a).size()) - 1) - 1; i >= 0; i--) {
      int b = lca(a[i], a[i + 1]);
      if (!vis[b]) a.push_back(b), vis[b] = 1;
    }
    sort((a).begin(), (a).end(), cmp);
    vector<int> stk{a[0]};
    for (int i = (1); i < (((int)(a).size())); i++) {
      while (rno[stk.back()] < lno[a[i]]) stk.pop_back();
      add(stk.back(), a[i]);
      stk.push_back(a[i]);
    }
    dfs(R, -1, 0);
    ;
    long long Ans = 0;
    for (int i = 0; i < (M + 1); i++) Ans = (Ans + ans[i]) % P;
    cout << Ans << endl;
    for (auto x : a) vis[x] = piv[x] = 0, go[x].clear();
  }
} tr;
int main() {
  prepare();
  int n, q;
  cin >> n >> q;
  tr.init(n, 0);
  tr.read();
  tr.build();
  while (q--) {
    ;
    int k, m, r;
    cin >> k >> m >> r;
    --r;
    vector<int> a(k);
    for (int i = 0; i < (k); i++) cin >> a[i], --a[i];
    tr.solve(a, m, r);
  }
  return 0;
}
