#include <bits/stdc++.h>   using namespace std;   int top = 0;   int N, Q, NN;   int K, M, R;   vector<int> Adj[100005];   int dep[100005];   int anc[100005][21];   int pre[100005], pst[100005], tt;   void dfs(int u) {     pre[u] = ++tt;     for (int j = 1; j <= 20; j++) {       if (dep[u] <= (1 << j)) break;       anc[u][j] = anc[anc[u][j - 1]][j - 1];     }     int v;     for (int k = 0; k < Adj[u].size(); k++) {       v = Adj[u][k];       if (v == anc[u][0]) continue;       anc[v][0] = u;       dep[v] = dep[u] + 1;       dfs(v);     }     pst[u] = ++tt;   }   int lca(int u, int v) {     if (dep[u] < dep[v]) swap(u, v);     for (int j = 20; j >= 0; j--) {       if (dep[anc[u][j]] >= dep[v]) {         u = anc[u][j];       }     }     if (u == v) return u;     for (int j = 20; j >= 0; j--) {       if (anc[u][j] != anc[v][j]) {         u = anc[u][j];         v = anc[v][j];       }     }     return anc[u][0];   }   int h[100005], c[2 * 100005];   int lbt(int x) { return x & (-x); }   void update(int x, int dv) {     for (; x <= NN; x += lbt(x)) {       c[x] += dv;     }   }   int getsum(int x) {     int ans = 0;     for (; x > 0; x -= lbt(x)) {       ans += c[x];     }     return ans;   }   bool cmp(const int& a, const int& b) { return dep[a] < dep[b]; }   int query(int u, int lca) { return getsum(pre[u] - 1) - getsum(pre[lca] - 1); }   int a[100005];   bool vis[100005];   long long dp[100005][305];   int work() {     int u, z;     for (int i = 1; i <= K; i++) {       u = a[i];       update(pre[u], 1);       update(pst[u], -1);       vis[a[i]] = 1;     }     int x;     for (int i = 1; i <= K; i++) {       u = a[i];       z = lca(u, R);       if (u == R)         h[i] = 0;       else if (u == z)         h[i] = query(R, u) - (vis[u] == true) + (vis[R] == true);       else if (z == R)         h[i] = query(u, R);       else         h[i] = query(u, z) + query(R, z) - (vis[z] == true) + (vis[R] == true);     }     sort(h + 1, h + 1 + K);     dp[1][1] = 1;     for (int i = 2; i <= K; i++) {       for (int j = 1; j <= M; j++) {         if (j > h[i])           dp[i][j] = ((long long)dp[i - 1][j] * (j - h[i]) % int(1e9 + 7) +                       dp[i - 1][j - 1]) %                      int(1e9 + 7);         else           dp[i][j] = 0;       }     }     long long ans = 0;     for (int j = 1; j <= M; j++) {       ans = (ans + dp[K][j]) % int(1e9 + 7);     }     for (int i = 1; i <= K; i++) {       u = a[i];       update(pre[u], -1);       update(pst[u], +1);       vis[a[i]] = 0;     }     return ans;   }   int main() {     scanf( %d%d , &N, &Q);     int u, v;     for (int i = 1; i < N; i++) {       scanf( %d%d , &u, &v);       Adj[u].push_back(v);       Adj[v].push_back(u);     }     dep[1] = 1;     dfs(1);     NN = 2 * N;     while (Q--) {       scanf( %d%d%d , &K, &M, &R);       for (int i = 1; i <= K; i++) {         scanf( %d , &a[i]);       }       printf( %d n , work());     }     return 0;   }   