#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <bitset>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>
#include <algorithm>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <ctime>
#include <chrono>

#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,avx2,tune=native")

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << x << endl;
#else
    #define dbg(x)
#endif

#define pb push_back
#define ppb pop_back()
#define mp make_pair
#define fi(a, b) for (int i = a; i < b; i++)
#define fj(a, b) for (int j = a; j < b; j++)
#define fk(a, b) for (int k = a; k < b; k++)
#define fi1(a, b) for (int i = a - 1; i >= b; i--)
#define fj1(a, b) for (int j = a - 1; j >= b; j--)
#define fk1(a, b) for (int k = a - 1; k >= b; k--)
#define fx(x, a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

using namespace std;

template<typename T1, typename T2>inline void mine(T1 &x, const T2 &y) { if (y < x) x = y; }
template<typename T1, typename T2>inline void maxe(T1 &x, const T2 &y) { if (x < y) x = y; }

ostream& operator << (ostream &out, const vector<int> &b) {
    for (auto k : b) out << k << ' ';
    return out;
}

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;

const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 100010;
const double EPS = 1e-9;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

inline int add(int a, int b) {
    a += b;
    if (a >= MOD) return a - MOD;
    return a;
}

inline int mult(int a, int b) {
    return 1ll * a * b % MOD;
}

int BIT[2][MX];

int get(int v, int i) {
    int ans = 0;
    for (; i > 0; i -= i&-i)
        ans += BIT[v][i];
    return ans;
}

int getlr(int v, int l, int r) {
    return get(v, r) - get(v, l - 1);
}

void upd(int v, int i, int x) {
    assert(i != 0);
    for (; i < MX; i += i&-i)
        BIT[v][i] += x;
}

void updlr(int v, int l, int r, int x) {
    assert(l != 0);
    assert(r + 1 != 0);
    upd(v, l, x);
    upd(v, r + 1, -x);
}

vi g[MX];
int tin[MX], tout[MX], timus = 1;
vvi bounds[MX];

void dfs(int v, int p = -1) {
    tin[v] = timus++;
    fx(to, g[v]) {
        if (to == p) continue;
        dfs(to, v);
    }
    tout[v] = timus - 1;
    bounds[v].pb({tin[v], tout[v], 1});
}

int gone[MX];
vi reqs[MX];
vi verts[MX];
int m[MX];
int ans[MX];

int dp[MX][301];

void walk(int v, int pr = -1) {
    bounds[v] = {{1, timus - 1, 1}};
    fx(id, reqs[v]) {

        dp[0][0] = 1;
        int i = 1;
        fx(w, verts[id]) {
            int h = get(0, tin[w]);
            fx(bnd, bounds[w])
                h += getlr(1, bnd[0], bnd[1]) * bnd[2];
            for (int j = 1; j <= m[id]; ++j) {
                dp[i][j] = add(dp[i - 1][j - 1], mult(dp[i - 1][j], max(0, j - h)));
            }
            ++i;

            upd(1, tin[w], 1);
            fx(bnd, bounds[w])
                updlr(0, bnd[0], bnd[1], bnd[2]);
        }
        for (int j = 0; j <= m[id]; ++j)
            ans[id] = add(ans[id], dp[i - 1][j]);

        fx(w, verts[id]) {
            upd(1, tin[w], -1);
            fx(bnd, bounds[w])
                updlr(0, bnd[0], bnd[1], -bnd[2]);
        }

    }
    fx(to, g[v]) {
        if (to == pr) continue;
        bounds[v].pb({tin[to], tout[to], -1});
        walk(to, v);
        bounds[v].ppb;
    }
    bounds[v] = {{tin[v], tout[v], 1}};
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n, q;
    cin >> n >> q;
    fi(0, n - 1) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        g[a].pb(b);
        g[b].pb(a);
    }
    dfs(0);
    fi(0, q) {
        int k, r;
        cin >> k >> m[i] >> r;
        --r;
        reqs[r].pb(i);
        verts[i].resize(k);
        fx(v, verts[i]) {
            cin >> v;
            --v;
            dbg(tin[v]);
        }
    }
    memset(gone, -1, sizeof(gone));
    walk(0);
    fi(0, q)
        cout << ans[i] << '\n';
}


#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <bitset>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>
#include <algorithm>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <ctime>
#include <chrono>

#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,avx2,tune=native")

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << x << endl;
#else
    #define dbg(x)
#endif

#define pb push_back
#define ppb pop_back()
#define mp make_pair
#define fi(a, b) for (int i = a; i < b; i++)
#define fj(a, b) for (int j = a; j < b; j++)
#define fk(a, b) for (int k = a; k < b; k++)
#define fi1(a, b) for (int i = a - 1; i >= b; i--)
#define fj1(a, b) for (int j = a - 1; j >= b; j--)
#define fk1(a, b) for (int k = a - 1; k >= b; k--)
#define fx(x, a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

using namespace std;

template<typename T1, typename T2>inline void mine(T1 &x, const T2 &y) { if (y < x) x = y; }
template<typename T1, typename T2>inline void maxe(T1 &x, const T2 &y) { if (x < y) x = y; }

ostream& operator << (ostream &out, const vector<int> &b) {
    for (auto k : b) out << k << ' ';
    return out;
}

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;

const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 100010;
const double EPS = 1e-9;
const int PW = 20;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int mult(int a, int b) {
    return 1ll * a * b % MOD;
}

int add(int a, int b) {
    a += b;
    if (a >= MOD) return a - MOD;
    return a;
}

int BIT[MX];

int get(int i) {
    int ans = 0;
    for (; i > 0; i -= i&-i)
        ans += BIT[i];
    return ans;
}

void upd(int i, int x) {
    for (; i < MX; i += i&-i)
        BIT[i] += x;
}

vi g[MX];
int tin[MX], tout[MX], timer = 1;
int up[PW][MX];

void dfs(int v, int pr) {
    up[0][v] = pr;
    fi(1, PW) up[i][v] = up[i - 1][up[v][i - 1]];
    tin[v] = timer++;
    fx(to, g[v]) {
        if (to != pr) {
            dfs(to, v);
        }
    }
    tout[v] = timer;
}

bool anc(int a, int b) {
    return tin[a] <= tin[b] && tout[b] <= tout[a];
}

int lca(int a, int b) {
    if (anc(a, b)) return a;
    if (anc(b, a)) return b;
    fi1(PW, 0) {
        if (!anc(up[i][a], b)) {
            a = up[i][a];
        }
    }
    return up[0][a];
}

void add(int v) {
    upd(tin[v], 1);
    upd(tout[v], -1);
}

void del(int v) {
    upd(tin[v], -1);
    upd(tout[v], 1);
}

int upsum(int v) {
    return get(tin[v]);
}

int geth(int v, int r) {
    int c = lca(v, r);
    return upsum(v) + upsum(r) - upsum(c) - (c ? upsum(up[0][c]) : 0);
}

int dp[MX][301];
int h[MX];

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    // thx to fedoseev.timofey for so pretty realization that I decided to resubmit this problem

    int n, q;
    cin >> n >> q;
    fi(0, n - 1) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        g[a].pb(b);
        g[b].pb(a);
    }
    dfs(0, 0);
    while (q--) {
        int k, m, r;
        cin >> k >> m >> r;
        --r;
        vi verts(k);
        fx(v, verts) {
            cin >> v;
            add(--v);
        }
        fx(v, verts) h[v] = geth(v, r) - 1;
        sort(all(verts), [&](int a, int b) {
            return h[a] < h[b];
        });

        dp[0][0] = 1;
        fi(1, k + 1) {
            fj(1, m + 1) {
                dp[i][j] = add(dp[i - 1][j - 1], mult(dp[i - 1][j], max(0, j - h[verts[i - 1]])));
            }
        }
        int ans = 0;
        fj(1, m + 1) ans = add(ans, dp[k][j]);
        cout << ans << '\n';

        fx(v, verts) del(v);
    }
}


#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <bitset>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>
#include <algorithm>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <ctime>
#include <chrono>

#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,avx2,tune=native")

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << x << endl;
#else
    #define dbg(x)
#endif

#define pb push_back
#define ppb pop_back()
#define mp make_pair
#define fi(a, b) for (int i = a; i < b; i++)
#define fj(a, b) for (int j = a; j < b; j++)
#define fk(a, b) for (int k = a; k < b; k++)
#define fi1(a, b) for (int i = a - 1; i >= b; i--)
#define fj1(a, b) for (int j = a - 1; j >= b; j--)
#define fk1(a, b) for (int k = a - 1; k >= b; k--)
#define fx(x, a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

using namespace std;

template<typename T1, typename T2>inline void mine(T1 &x, const T2 &y) { if (y < x) x = y; }
template<typename T1, typename T2>inline void maxe(T1 &x, const T2 &y) { if (x < y) x = y; }

ostream& operator << (ostream &out, const vector<int> &b) {
    for (auto k : b) out << k << ' ';
    return out;
}

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;

const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 100010;
const double EPS = 1e-9;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

inline int add(int a, int b) {
    a += b;
    if (a >= MOD) return a - MOD;
    return a;
}

inline int mult(int a, int b) {
    return 1ll * a * b % MOD;
}

int BIT[2][MX];

int get(int v, int i) {
    int ans = 0;
    for (; i > 0; i -= i&-i)
        ans += BIT[v][i];
    return ans;
}

int getlr(int v, int l, int r) {
    return get(v, r) - get(v, l - 1);
}

void upd(int v, int i, int x) {
    for (; i < MX; i += i&-i)
        BIT[v][i] += x;
}

void updlr(int v, int l, int r, int x) {
    upd(v, l, x);
    upd(v, r + 1, -x);
}

vi g[MX];
int tin[MX], tout[MX], timus = 1;
vvi bounds[MX];

void dfs(int v, int p = -1) {
    tin[v] = timus++;
    fx(to, g[v]) {
        if (to == p) continue;
        dfs(to, v);
    }
    tout[v] = timus - 1;
    bounds[v].pb({tin[v], tout[v], 1});
}

vi reqs[MX];
vi verts[MX];
int m[MX];
int ans[MX];

int dp[MX][301];

void walk(int v, int pr = -1) {
    bounds[v] = {{1, timus - 1, 1}};
    fx(id, reqs[v]) {
        for (int i = 0; i <= verts[id].size(); ++i) for (int j = 0; j <= m[id]; ++j) dp[i][j] = 0;
        dp[0][0] = 1;
        int i = 1;
        fx(w, verts[id]) {
            int h = get(0, tin[w]);
            fx(bnd, bounds[w]) {
                h += getlr(1, bnd[0], bnd[1]) * bnd[2];
                updlr(0, bnd[0], bnd[1], bnd[2]);
            }
            upd(1, tin[w], 1);

            for (int j = 1; j <= m[id]; ++j) {
                dp[i][j] = add(dp[i - 1][j - 1], mult(dp[i - 1][j], max(0, j - h)));
            }
            ++i;
        }
        for (int j = 0; j <= m[id]; ++j)
            ans[id] = add(ans[id], dp[i - 1][j]);

        fx(w, verts[id]) {
            upd(1, tin[w], -1);
            fx(bnd, bounds[w])
                updlr(0, bnd[0], bnd[1], -bnd[2]);
        }

    }
    fx(to, g[v]) {
        if (to == pr) continue;
        bounds[v].pb({tin[to], tout[to], -1});
        walk(to, v);
        bounds[v].ppb;
    }
    bounds[v] = {{tin[v], tout[v], 1}};
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n, q;
    cin >> n >> q;
    fi(0, n - 1) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        g[a].pb(b);
        g[b].pb(a);
    }
    dfs(0);
    fi(0, q) {
        int k, r;
        cin >> k >> m[i] >> r;
        --r;
        reqs[r].pb(i);
        verts[i].resize(k);
        fx(v, verts[i]) {
            cin >> v;
            --v;
            dbg(tin[v]);
        }
    }
    walk(0);
    fi(0, q)
        cout << ans[i] << '\n';
}


#include<bits/stdc++.h>
using namespace std;

#define debug puts("YES");
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long

#define lrt int l,int r,int rt
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define root l,r,rt
#define mst(a,b) memset((a),(b),sizeof(a))
#define pii pair<int,int>
#define fi first
#define se second
#define mk(x,y) make_pair(x,y)
const int mod=1e9+7;
const int maxn=1e5+5;
const int ub=1e6;
const double inf=1e-4;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
int n,q,x,y;
///前式链向星
struct node{
    int u,nxt;
}e[maxn<<1];
int head[maxn],tot=0;
void add(int x,int y){
    e[tot]=node{y,head[x]};
    head[x]=tot++;
}
void init(){
    mst(head,-1),tot=0;
}

int pl[maxn],pr[maxn],bit[maxn];///深度
void refresh(int x,int d){
    for(;x<maxn;bit[x]+=d,x+=x&-x);
}
int sum(int x){
    int ret=0;for(;x>0;ret+=bit[x],x-=x&-x);return ret;
}
int st[maxn][20],dep[maxn];
void dfs(int u,int pre){
    pl[u]=++tot;
    dep[u]=dep[pre]+1;
    st[u][0]=pre;rep(i,1,20) st[u][i]=st[st[u][i-1]][i-1];
    for(int i=head[u];~i;i=e[i].nxt){
        int v=e[i].u;
        if(v==pre) continue;
        dfs(v,u);
    }
    pr[u]=tot;
}
int lca(int u,int v){
    if(dep[u]<dep[v]) swap(u,v);
    for(int i=19;i>=0;i--) if(dep[st[u][i]]>=dep[v])
        u=st[u][i];
    if(u==v) return u;
    for(int i=19;i>=0;i--) if(st[u][i]&&st[u][i]!=st[v][i])
        u=st[u][i],v=st[v][i];
    return st[u][0];
}
ll dp[maxn][305];
int k,m,r,a[maxn],f[maxn],vis[maxn];
int main(){
    init();///初始化
    scanf("%d%d",&n,&q);
    rep(i,0,n-1){
        scanf("%d%d",&x,&y);
        add(x,y),add(y,x);
    }
    tot=0;dfs(1,0);
    rep(i,0,q){
        mst(vis,0),mst(bit,0);
        scanf("%d%d%d",&k,&m,&r);
        rep(i,1,k+1){
            scanf("%d",&a[i]);
            vis[a[i]]=1;
            refresh(pl[a[i]],1);
            refresh(pr[a[i]]+1,-1);
        }
        rep(i,1,k+1){
            int rt=lca(r,a[i]);
            f[i]=sum(pl[a[i]])+sum(pl[r])-2*sum(pl[rt])+vis[rt]-1;///减去自己
        }
        sort(f+1,f+1+k);
        mst(dp,0),dp[0][0]=1;
        rep(i,1,k+1) rep(j,f[i],m+1) dp[i][j]=dp[i-1][j-1]+dp[i-1][j]*1LL*(j-f[i]);
        ///rep(i,1,m+1) dp[k][i]+=dp[k][i-1];
        ll ans=0;rep(i,1,m+1) ans+=dp[k][i];
        printf("%lld\n",ans);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long
#define mst(a,b) memset((a),(b),sizeof(a))
const int mod=1e9+7;
const int maxn=1e5+5;
const int ub=1e6;
const double inf=1e-4;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
int n,q,x,y;
///前式链向星
struct node{
    int u,nxt;
}e[maxn<<1];
int head[maxn],tot=0;
inline void add(int x,int y){
    e[tot]=node{y,head[x]};
    head[x]=tot++;
}
inline void init(){
    mst(head,-1),tot=0;
}

int pl[maxn],pr[maxn],bit[maxn];///深度
inline void refresh(int x,int d){
    for(;x<maxn;bit[x]+=d,x+=x&-x);
}
inline int sum(int x){
    int ret=0;for(;x>0;ret+=bit[x],x-=x&-x);return ret;
}
int st[maxn][22],dep[maxn];
inline void dfs(int u,int pre){
    pl[u]=++tot;
    dep[u]=dep[pre]+1;
    st[u][0]=pre;rep(i,1,20) st[u][i]=st[st[u][i-1]][i-1];
    for(int i=head[u];~i;i=e[i].nxt){
        int v=e[i].u;
        if(v==pre) continue;
        dfs(v,u);
    }
    pr[u]=tot;
}
inline int lca(int u,int v){
    if(u==v) return u;
    if(dep[u]<dep[v]) swap(u,v);
    for(int i=19;i>=0;i--) if(dep[st[u][i]]>=dep[v])
        u=st[u][i];
    if(u==v) return u;
    for(int i=19;i>=0;i--) if(st[u][i]!=st[v][i])
        u=st[u][i],v=st[v][i];
    return st[u][0];
}
ll dp[maxn];
int k,m,r,a[maxn],f[maxn],vis[maxn];
int main(){
    init();///初始化
    scanf("%d%d",&n,&q);
    rep(i,0,n-1){
        scanf("%d%d",&x,&y);
        add(x,y),add(y,x);
    }
    tot=0;dfs(1,0);
    rep(i,0,q){
        mst(bit,0),mst(vis,0);
        scanf("%d%d%d",&k,&m,&r);
        rep(i,1,k+1){
            scanf("%d",&a[i]);
            vis[a[i]]=1;
            refresh(pl[a[i]],1);
            refresh(pr[a[i]]+1,-1);
        }
        rep(i,1,k+1){
            int LCA=lca(r,a[i]);
            f[i]=sum(pl[a[i]])+sum(pl[r])-2*sum(pl[LCA])+vis[LCA]-1;///减去自己
        }
        sort(f+1,f+1+k);
        mst(dp,0),dp[0]=1;
        rep(i,1,k+1) for(int j=min(i,m);j>=0;j--){
            if(j<f[i]) dp[j]=0;
            else dp[j]=(dp[j-1]+1LL*(j-f[i])*dp[j]%mod)%mod;
        }
        ll ans=0;rep(i,1,m+1) (ans+=dp[i])%=mod;
        cout<<ans<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long
#define mst(a,b) memset((a),(b),sizeof(a))
const int mod=1e9+7;
const int maxn=1e5+5;
const int ub=1e6;
const double inf=1e-4;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
int n,q,x,y;
///前式链向星
struct node{
    int u,nxt;
}e[maxn<<1];
int head[maxn],tot=0;
inline void add(int x,int y){
    e[tot]=node{y,head[x]};
    head[x]=tot++;
}
inline void init(){
    mst(head,-1),tot=0;
}

int pl[maxn],pr[maxn],bit[maxn];///深度
inline void refresh(int x,int d){
    for(;x<maxn;bit[x]+=d,x+=x&-x);
}
inline int sum(int x){
    int ret=0;for(;x>0;ret+=bit[x],x-=x&-x);return ret;
}
int st[maxn][22],dep[maxn];
inline void dfs(int u,int pre){
    pl[u]=++tot;
    dep[u]=dep[pre]+1;
    st[u][0]=pre;rep(i,1,20) st[u][i]=st[st[u][i-1]][i-1];
    for(int i=head[u];~i;i=e[i].nxt){
        int v=e[i].u;
        if(v==pre) continue;
        dfs(v,u);
    }
    pr[u]=tot;
}
inline int lca(int u,int v){
    if(u==v) return u;
    if(dep[u]<dep[v]) swap(u,v);
    for(int i=19;i>=0;i--) if(dep[st[u][i]]>=dep[v])
        u=st[u][i];
    if(u==v) return u;
    for(int i=19;i>=0;i--) if(st[u][i]!=st[v][i])
        u=st[u][i],v=st[v][i];
    return st[u][0];
}
ll dp[maxn];
int k,m,r,a[maxn],f[maxn],vis[maxn];
int main(){
    init();///初始化
    scanf("%d%d",&n,&q);
    rep(i,0,n-1){
        scanf("%d%d",&x,&y);
        add(x,y),add(y,x);
    }
    tot=0;dfs(1,0);
    rep(i,0,q){
        scanf("%d%d%d",&k,&m,&r);
        rep(i,1,k+1){
            scanf("%d",&a[i]);
            vis[a[i]]=1;
            refresh(pl[a[i]],1);
            refresh(pr[a[i]]+1,-1);
        }
        int tmp=sum(pl[r]);
        rep(i,1,k+1){
            int LCA=lca(r,a[i]);
            f[i]=sum(pl[a[i]])+tmp-2*sum(pl[LCA])+vis[LCA]-1;///减去自己
        }
        rep(i,1,k+1){
            vis[a[i]]=0;
            refresh(pl[a[i]],-1);
            refresh(pr[a[i]]+1,1);
        }
        if(f[k]>=m) {puts("0");continue;}
        sort(f+1,f+1+k);
        mst(dp,0),dp[0]=1;
        rep(i,1,k+1) for(int j=min(i,m);j>=0;j--){
            if(j<=f[i]) dp[j]=0;
            else dp[j]=(dp[j-1]+dp[j]*(j-f[i])%mod)%mod;
        }
        ll ans=0;rep(i,1,m+1) (ans+=dp[i])%=mod;
        printf("%lld\n",ans);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long
#define mst(a,b) memset((a),(b),sizeof(a))
const int mod=1e9+7;
const int maxn=1e5+5;
const int ub=1e6;
const double inf=1e-4;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
int n,q,x,y;
///前式链向星
struct node{
    int u,nxt;
}e[maxn<<1];
int head[maxn],tot=0;
inline void add(int x,int y){
    e[tot]=node{y,head[x]};
    head[x]=tot++;
}
inline void init(){
    mst(head,-1),tot=0;
}

int pl[maxn],pr[maxn],bit[maxn];///深度
inline void refresh(int x,int d){
    for(;x<maxn;bit[x]+=d,x+=x&-x);
}
inline int sum(int x){
    int ret=0;for(;x>0;ret+=bit[x],x-=x&-x);return ret;
}
int st[maxn][22],dep[maxn];
inline void dfs(int u,int pre){
    pl[u]=++tot;
    dep[u]=dep[pre]+1;
    st[u][0]=pre;rep(i,1,20) st[u][i]=st[st[u][i-1]][i-1];
    for(int i=head[u];~i;i=e[i].nxt){
        int v=e[i].u;
        if(v==pre) continue;
        dfs(v,u);
    }
    pr[u]=tot;
}
inline int lca(int u,int v){
    if(u==v) return u;
    if(dep[u]<dep[v]) swap(u,v);
    for(int i=19;i>=0;i--) if(dep[st[u][i]]>=dep[v])
        u=st[u][i];
    if(u==v) return u;
    for(int i=19;i>=0;i--) if(st[u][i]!=st[v][i])
        u=st[u][i],v=st[v][i];
    return st[u][0];
}
ll dp[maxn];
int k,m,r,a[maxn],f[maxn],vis[maxn];
int main(){
    init();///初始化
    scanf("%d%d",&n,&q);
    rep(i,0,n-1){
        scanf("%d%d",&x,&y);
        add(x,y),add(y,x);
    }
    tot=0;dfs(1,0);
    rep(i,0,q){
        scanf("%d%d%d",&k,&m,&r);
        rep(i,1,k+1){
            scanf("%d",&a[i]);
            vis[a[i]]=1;
            refresh(pl[a[i]],1);
            refresh(pr[a[i]]+1,-1);
        }
        rep(i,1,k+1){
            int LCA=lca(r,a[i]);
            f[i]=sum(pl[a[i]])+sum(pl[r])-2*sum(pl[LCA])+vis[LCA]-1;///减去自己
        }
        rep(i,1,k+1){
            vis[a[i]]=0;
            refresh(pl[a[i]],-1);
            refresh(pr[a[i]]+1,1);
        }
        if(f[k]>=m) {puts("0");continue;}
        sort(f+1,f+1+k);
        mst(dp,0),dp[0]=1;
        rep(i,1,k+1) for(int j=min(i,m);j>=0;j--){
            if(j<=f[i]) dp[j]=0;
            else dp[j]=(dp[j-1]+dp[j]*(j-f[i])%mod)%mod;
        }
        ll ans=0;rep(i,1,m+1) (ans+=dp[i])%=mod;
        printf("%lld\n",ans);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long
#define mst(a,b) memset((a),(b),sizeof(a))
const int mod=1e9+7;
const int maxn=1e5+5;
const int ub=1e6;
const double inf=1e-4;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
int n,q,x,y;
///前式链向星
struct node{
    int u,nxt;
}e[maxn<<1];
int head[maxn],tot=0;
inline void add(int x,int y){
    e[tot]=node{y,head[x]};
    head[x]=tot++;
}
inline void init(){
    mst(head,-1),tot=0;
}

int pl[maxn],pr[maxn],bit[maxn];///深度
inline void refresh(int x,int d){
    for(;x<maxn;bit[x]+=d,x+=x&-x);
}
inline int sum(int x){
    int ret=0;for(;x>0;ret+=bit[x],x-=x&-x);return ret;
}
int st[maxn][22],dep[maxn];
inline void dfs(int u,int pre){
    pl[u]=++tot;
    dep[u]=dep[pre]+1;
    st[u][0]=pre;rep(i,1,20) st[u][i]=st[st[u][i-1]][i-1];
    for(int i=head[u];~i;i=e[i].nxt){
        int v=e[i].u;
        if(v==pre) continue;
        dfs(v,u);
    }
    pr[u]=tot;
}
inline int lca(int u,int v){
    if(u==v) return u;
    if(dep[u]<dep[v]) swap(u,v);
    for(int i=19;i>=0;i--) if(dep[st[u][i]]>=dep[v])
        u=st[u][i];
    if(u==v) return u;
    for(int i=19;i>=0;i--) if(st[u][i]!=st[v][i])
        u=st[u][i],v=st[v][i];
    return st[u][0];
}
ll dp[maxn];
int k,m,r,a[maxn],f[maxn],vis[maxn];
int main(){
    init();///初始化
    scanf("%d%d",&n,&q);
    rep(i,0,n-1){
        scanf("%d%d",&x,&y);
        add(x,y),add(y,x);
    }
    tot=0;dfs(1,0);
    rep(i,0,q){
        mst(bit,0),mst(vis,0);
        scanf("%d%d%d",&k,&m,&r);
        rep(i,1,k+1){
            scanf("%d",&a[i]);
            vis[a[i]]=1;
            refresh(pl[a[i]],1);
            refresh(pr[a[i]]+1,-1);
        }
        rep(i,1,k+1){
            int LCA=lca(r,a[i]);
            f[i]=sum(pl[a[i]])+sum(pl[r])-2*sum(pl[LCA])+vis[LCA]-1;///减去自己
        }
        if(f[k]>=m) {puts("0");continue;}
        sort(f+1,f+1+k);
        mst(dp,0),dp[0]=1;
        rep(i,1,k+1) for(int j=min(i,m);j>=0;j--){
            if(j<=f[i]) dp[j]=0;
            else dp[j]=(dp[j-1]+dp[j]*(j-f[i])%mod)%mod;
        }
        ll ans=0;rep(i,1,m+1) (ans+=dp[i])%=mod;
        cout<<ans<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>

#define INF 1e18

#define LL long long

#define sc(x) scanf("%d",&x)

#define scc(x,y) scanf("%d%d",&x,&y)

#define sccc(x,y,z) scanf("%d%d%d",&x,&y,&z)

using namespace std;

const int N = 100010;

const int mod = 1e9 + 7;

int l[N],r[N],dep[N],h[N],a[N],c[N],index;

int dp[N],f[N][20],n,q;

vector<int> g[N];

bool v[N];

void dfs(int x,int fa)

{

    l[x]=++index;

    for(int i=0;i<g[x].size();i++)

    {

        int y=g[x][i];

        if (y==fa) continue;

        dep[y]=dep[x]+1;

        f[y][0]=x; dfs(y,x);

    }

    r[x]=index;

}

void ST()

{

    for(int j=0;j<17;j++)

        for(int i=1;i<=n;i++)

            f[i][j+1]=f[f[i][j]][j];

}

inline int lca(int u,int v)

{

    if (u==v) return u;

    if (dep[v]>dep[u]) swap(u,v);

    for(int i=18;i>=0;i--)

        if (dep[f[u][i]]>=dep[v]) u=f[u][i];

    if (u==v) return u;

    for(int i=18;i>=0;i--)

        if (f[u][i]!=f[v][i]) u=f[u][i],v=f[v][i];

    return f[u][0];

}

inline void update(int x,int y)

{

    for(int i=x;i<N;i+=i&-i)

        c[i]+=y;

}

inline int getsum(int x)

{

    int res=0;

    for(int i=x;i;i-=i&-i)

        res+=c[i];

    return res;

}

int main()

{

    scc(n,q);

    for(int i=1;i<n;i++)

    {

        int x,y;

        scc(x,y);

        g[x].push_back(y);

        g[y].push_back(x);

    }

    dep[1]=1;

    dfs(1,-1); ST();

    while(q--)

    {

        int k,m,rt;

        sccc(k,m,rt);

        for(int i=1;i<=k;i++)

        {

            sc(a[i]);

            v[a[i]]=1;

            update(l[a[i]],1);

            update(r[a[i]]+1,-1);

        }

        int root=getsum(l[rt]);

        for(int i=1;i<=k;i++)

        {

            int LCA=lca(rt,a[i]);

            h[i]=getsum(l[a[i]])+root-2*getsum(l[LCA])+(v[LCA]==1)-1;

        }

        sort(h+1,h+1+k);

        for(int i=1;i<=k;i++)

        {

            v[a[i]]=0;

            update(l[a[i]],-1);

            update(r[a[i]]+1,1);

        }

        memset(dp,0,sizeof(dp));

        dp[0]=1;

        if (h[k]>=m) printf("0\n");

        else

        {

            for(int i=1;i<=k;i++)

            {

                for(int j=min(i,m);j>=0;j--)

                    if (j<=h[i]) dp[j]=0;

                    else dp[j]=((LL)dp[j]*(j-h[i])%mod+dp[j-1])%mod;

            }

            LL ans=0;

            for(int i=1;i<=m;i++)

                ans=(ans+dp[i])%mod;

            printf("%lld\n",ans);

        }

    }

    return 0;

}


#include<bits/stdc++.h>
using namespace std;
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long
#define mst(a,b) memset((a),(b),sizeof(a))
const int mod=1e9+7;
const int maxn=1e5+5;
const int ub=1e6;
const double inf=1e-4;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
int n,q,x,y;
///前式链向星
struct node{
    int u,nxt;
}e[maxn<<1];
int head[maxn],tot=0;
inline void add(int x,int y){
    e[tot]=node{y,head[x]};
    head[x]=tot++;
}
inline void init(){
    mst(head,-1),tot=0;
}

int pl[maxn],pr[maxn],bit[maxn];///深度
inline void refresh(int x,int d){
    for(;x<maxn;bit[x]+=d,x+=x&-x);
}
inline int sum(int x){
    int ret=0;for(;x>0;ret+=bit[x],x-=x&-x);return ret;
}
int st[maxn][22],dep[maxn];
inline void dfs(int u,int pre){
    pl[u]=++tot;
    dep[u]=dep[pre]+1;
    st[u][0]=pre;rep(i,1,20) st[u][i]=st[st[u][i-1]][i-1];
    for(int i=head[u];~i;i=e[i].nxt){
        int v=e[i].u;
        if(v==pre) continue;
        dfs(v,u);
    }
    pr[u]=tot;
}
inline int lca(int u,int v){
    if(u==v) return u;
    if(dep[u]<dep[v]) swap(u,v);
    for(int i=19;i>=0;i--) if(dep[st[u][i]]>=dep[v])
        u=st[u][i];
    if(u==v) return u;
    for(int i=19;i>=0;i--) if(st[u][i]&&st[u][i]!=st[v][i])
        u=st[u][i],v=st[v][i];
    return st[u][0];
}
int dp[maxn];
int k,m,r,a[maxn],f[maxn],vis[maxn];
int main(){
    init();///初始化
    mst(st,0),mst(dep,0);
    scanf("%d%d",&n,&q);
    rep(i,0,n-1){
        scanf("%d%d",&x,&y);
        add(x,y),add(y,x);
    }
    tot=0;dfs(1,0);
    rep(i,0,q){
        mst(bit,0),mst(vis,0);
        scanf("%d%d%d",&k,&m,&r);
        rep(i,1,k+1){
            scanf("%d",&a[i]);
            vis[a[i]]=1;
            refresh(pl[a[i]],1);
            refresh(pr[a[i]]+1,-1);
        }
        rep(i,1,k+1){
            int rt=lca(r,a[i]);
            f[i]=sum(pl[a[i]])+sum(pl[r])-2*sum(pl[rt])+vis[rt]-1;///减去自己
        }
        sort(f+1,f+1+k);
        mst(dp,0),dp[0]=1;
        rep(i,1,k+1) for(int j=m;j>=f[i];j--) dp[j]=dp[j-1]+dp[j]*(j-f[i]);
        ll ans=0;rep(i,1,m+1) ans+=dp[i];
        cout<<ans<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long
#define mst(a,b) memset((a),(b),sizeof(a))
const int mod=1e9+7;
const int maxn=1e5+5;
const int ub=1e6;
const double inf=1e-4;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
int n,q,x,y;
///前式链向星
struct node{
    int u,nxt;
}e[maxn<<1];
int head[maxn],tot=0;
inline void add(int x,int y){
    e[tot]=node{y,head[x]};
    head[x]=tot++;
}
inline void init(){
    mst(head,-1),tot=0;
}

int pl[maxn],pr[maxn],bit[maxn];///深度
inline void refresh(int x,int d){
    for(;x<maxn;bit[x]+=d,x+=x&-x);
}
inline int sum(int x){
    int ret=0;for(;x>0;ret+=bit[x],x-=x&-x);return ret;
}
int st[maxn][22],dep[maxn];
inline void dfs(int u,int pre){
    pl[u]=++tot;
    dep[u]=dep[pre]+1;
    st[u][0]=pre;rep(i,1,20) st[u][i]=st[st[u][i-1]][i-1];
    for(int i=head[u];~i;i=e[i].nxt){
        int v=e[i].u;
        if(v==pre) continue;
        dfs(v,u);
    }
    pr[u]=tot;
}
inline int lca(int u,int v){
    if(u==v) return u;
    if(dep[u]<dep[v]) swap(u,v);
    for(int i=19;i>=0;i--) if(dep[st[u][i]]>=dep[v])
        u=st[u][i];
    if(u==v) return u;
    for(int i=19;i>=0;i--) if(st[u][i]&&st[u][i]!=st[v][i])
        u=st[u][i],v=st[v][i];
    return st[u][0];
}
int dp[maxn];
int k,m,r,a[maxn],f[maxn],vis[maxn];
int main(){
    init();///初始化
    mst(st,0),mst(dep,0);
    scanf("%d%d",&n,&q);
    rep(i,0,n-1){
        scanf("%d%d",&x,&y);
        add(x,y),add(y,x);
    }
    tot=0;dfs(1,0);
    rep(i,0,q){
        scanf("%d%d%d",&k,&m,&r);
        rep(i,1,k+1){
            scanf("%d",&a[i]);
            vis[a[i]]=1;
            refresh(pl[a[i]],1);
            refresh(pr[a[i]]+1,-1);
        }
        rep(i,1,k+1){
            int rt=lca(r,a[i]);
            f[i]=sum(pl[a[i]])+sum(pl[r])-2*sum(pl[rt])+vis[rt]-1;///减去自己
        }
        sort(f+1,f+1+k);
        mst(dp,0),dp[0]=1;
        rep(i,1,k+1) for(int j=m;j>=f[i];j--) dp[j]=dp[j-1]+dp[j]*(j-f[i]);
        ll ans=0;rep(i,1,m+1) ans+=dp[i];
        printf("%lld\n",ans);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long
#define mst(a,b) memset((a),(b),sizeof(a))
const int mod=1e9+7;
const int maxn=1e5+5;
const int ub=1e6;
const double inf=1e-4;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
int n,q,x,y;
///前式链向星
struct node{
    int u,nxt;
}e[maxn<<1];
int head[maxn],tot=0;
inline void add(int x,int y){
    e[tot]=node{y,head[x]};
    head[x]=tot++;
}
inline void init(){
    mst(head,-1),tot=0;
}

int pl[maxn],pr[maxn],bit[maxn];///深度
inline void refresh(int x,int d){
    for(;x<maxn;bit[x]+=d,x+=x&-x);
}
inline int sum(int x){
    int ret=0;for(;x>0;ret+=bit[x],x-=x&-x);return ret;
}
int st[maxn][22],dep[maxn];
inline void dfs(int u,int pre){
    pl[u]=++tot;
    dep[u]=dep[pre]+1;
    st[u][0]=pre;rep(i,1,20) st[u][i]=st[st[u][i-1]][i-1];
    for(int i=head[u];~i;i=e[i].nxt){
        int v=e[i].u;
        if(v==pre) continue;
        dfs(v,u);
    }
    pr[u]=tot;
}
inline int lca(int u,int v){
    if(u==v) return u;
    if(dep[u]<dep[v]) swap(u,v);
    for(int i=19;i>=0;i--) if(dep[st[u][i]]>=dep[v])
        u=st[u][i];
    if(u==v) return u;
    for(int i=19;i>=0;i--) if(st[u][i]!=st[v][i])
        u=st[u][i],v=st[v][i];
    return st[u][0];
}
ll dp[maxn];
int k,m,r,a[maxn],f[maxn],vis[maxn];
int main(){
    init();///初始化
    scanf("%d%d",&n,&q);
    rep(i,0,n-1){
        scanf("%d%d",&x,&y);
        add(x,y),add(y,x);
    }
    tot=0;dfs(1,0);
    rep(i,0,q){
        scanf("%d%d%d",&k,&m,&r);
        rep(i,1,k+1){
            scanf("%d",&a[i]);
            vis[a[i]]=1;
            refresh(pl[a[i]],1);
            refresh(pr[a[i]]+1,-1);
        }
        rep(i,1,k+1){
            int LCA=lca(r,a[i]);
            f[i]=sum(pl[a[i]])+sum(pl[r])-2*sum(pl[LCA])+vis[LCA]-1;///减去自己
        }
        rep(i,1,k+1){
            vis[a[i]]=0;
            refresh(pl[a[i]],-1);
            refresh(pr[a[i]]+1,1);
        }
        if(f[k]>=m) {puts("0");continue;}
        sort(f+1,f+1+k);
        mst(dp,0),dp[0]=1;
        rep(i,1,k+1) for(int j=min(i,m);j>=0;j--){
            if(j<=f[i]) dp[j]=0;
            else dp[j]=(dp[j-1]+dp[j]*(j-f[i])%mod)%mod;
        }
        ll ans=0;rep(i,1,m+1) (ans+=dp[i])%=mod;
        cout<<ans<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long
#define mst(a,b) memset((a),(b),sizeof(a))
const int mod=1e9+7;
const int maxn=1e5+5;
const int ub=1e6;
const double inf=1e-4;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
int n,q,x,y;
///前式链向星
struct node{
    int u,nxt;
}e[maxn<<1];
int head[maxn],tot=0;
inline void add(int x,int y){
    e[tot]=node{y,head[x]};
    head[x]=tot++;
}
inline void init(){
    mst(head,-1),tot=0;
}

int pl[maxn],pr[maxn],bit[maxn];///深度
inline void refresh(int x,int d){
    for(;x<maxn;bit[x]+=d,x+=x&-x);
}
inline int sum(int x){
    int ret=0;for(;x>0;ret+=bit[x],x-=x&-x);return ret;
}
int st[maxn][22],dep[maxn];
inline void dfs(int u,int pre){
    pl[u]=++tot;
    dep[u]=dep[pre]+1;
    st[u][0]=pre;rep(i,1,20) st[u][i]=st[st[u][i-1]][i-1];
    for(int i=head[u];~i;i=e[i].nxt){
        int v=e[i].u;
        if(v==pre) continue;
        dfs(v,u);
    }
    pr[u]=tot;
}
inline int lca(int u,int v){
    if(u==v) return u;
    if(dep[u]<dep[v]) swap(u,v);
    for(int i=19;i>=0;i--) if(dep[st[u][i]]>=dep[v])
        u=st[u][i];
    if(u==v) return u;
    for(int i=19;i>=0;i--) if(st[u][i]!=st[v][i])
        u=st[u][i],v=st[v][i];
    return st[u][0];
}
ll dp[maxn];
int k,m,r,a[maxn],f[maxn],vis[maxn];
int main(){
    init();///初始化
    scanf("%d%d",&n,&q);
    rep(i,0,n-1){
        scanf("%d%d",&x,&y);
        add(x,y),add(y,x);
    }
    tot=0;dfs(1,0);
    rep(i,0,q){
        mst(bit,0),mst(vis,0);
        scanf("%d%d%d",&k,&m,&r);
        rep(i,1,k+1){
            scanf("%d",&a[i]);
            vis[a[i]]=1;
            refresh(pl[a[i]],1);
            refresh(pr[a[i]]+1,-1);
        }
        rep(i,1,k+1){
            int LCA=lca(r,a[i]);
            f[i]=sum(pl[a[i]])+sum(pl[r])-2*sum(pl[LCA])+vis[LCA]-1;///减去自己
        }
        if(f[k]>=m) {puts("0");continue;}
        sort(f+1,f+1+k);
        mst(dp,0),dp[0]=1;
        rep(i,1,k+1) for(int j=min(i,m);j>=1;j--){
            if(j<=f[i]) dp[j]=0;
            else dp[j]=(dp[j-1]+dp[j]*(j-f[i])%mod)%mod;
        }
        ll ans=0;rep(i,1,m+1) (ans+=dp[i])%=mod;
        cout<<ans<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long
#define mst(a,b) memset((a),(b),sizeof(a))
const int mod=1e9+7;
const int maxn=1e5+5;
const int ub=1e6;
const double inf=1e-4;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
int n,q,x,y;
///前式链向星
struct node{
    int u,nxt;
}e[maxn<<1];
int head[maxn],tot=0;
inline void add(int x,int y){
    e[tot]=node{y,head[x]};
    head[x]=tot++;
}
inline void init(){
    mst(head,-1),tot=0;
}

int pl[maxn],pr[maxn],bit[maxn];///深度
inline void refresh(int x,int d){
    for(;x<maxn;bit[x]+=d,x+=x&-x);
}
inline int sum(int x){
    int ret=0;for(;x>0;ret+=bit[x],x-=x&-x);return ret;
}
int st[maxn][22],dep[maxn];
inline void dfs(int u,int pre){
    pl[u]=++tot;
    dep[u]=dep[pre]+1;
    st[u][0]=pre;rep(i,1,20) st[u][i]=st[st[u][i-1]][i-1];
    for(int i=head[u];~i;i=e[i].nxt){
        int v=e[i].u;
        if(v==pre) continue;
        dfs(v,u);
    }
    pr[u]=tot;
}
inline int lca(int u,int v){
    if(u==v) return u;
    if(dep[u]<dep[v]) swap(u,v);
    for(int i=19;i>=0;i--) if(dep[st[u][i]]>=dep[v])
        u=st[u][i];
    if(u==v) return u;
    for(int i=19;i>=0;i--) if(st[u][i]&&st[u][i]!=st[v][i])
        u=st[u][i],v=st[v][i];
    return st[u][0];
}
int dp[maxn];
int k,m,r,a[maxn],f[maxn],vis[maxn];
int main(){
    init();///初始化
    mst(st,0),mst(dep,0);
    scanf("%d%d",&n,&q);
    rep(i,0,n-1){
        scanf("%d%d",&x,&y);
        add(x,y),add(y,x);
    }
    tot=0;dfs(1,0);
    rep(i,0,q){
        mst(vis,0),mst(bit,0);
        scanf("%d%d%d",&k,&m,&r);
        rep(i,1,k+1){
            scanf("%d",&a[i]);
            vis[a[i]]=1;
            refresh(pl[a[i]],1);
            refresh(pr[a[i]]+1,-1);
        }
        rep(i,1,k+1){
            int rt=lca(r,a[i]);
            f[i]=sum(pl[a[i]])+sum(pl[r])-2*sum(pl[rt])+vis[rt]-1;///减去自己
        }
        sort(f+1,f+1+k);
        mst(dp,0),dp[0]=1;
        rep(i,1,k+1) for(int j=m;j>=f[i];j--) dp[j]=dp[j-1]+dp[j]*(j-f[i]);
        ll ans=0;rep(i,1,m+1) ans+=dp[i];
        printf("%lld\n",ans);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long
#define mst(a,b) memset((a),(b),sizeof(a))
const int mod=1e9+7;
const int maxn=1e5+5;
const int ub=1e6;
const double inf=1e-4;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
int n,q,x,y;
///前式链向星
struct node{
    int u,nxt;
}e[maxn<<1];
int head[maxn],tot=0;
inline void add(int x,int y){
    e[tot]=node{y,head[x]};
    head[x]=tot++;
}
inline void init(){
    mst(head,-1),tot=0;
}

int pl[maxn],pr[maxn],bit[maxn];///深度
inline void refresh(int x,int d){
    for(;x<maxn;bit[x]+=d,x+=x&-x);
}
inline int sum(int x){
    int ret=0;for(;x>0;ret+=bit[x],x-=x&-x);return ret;
}
int st[maxn][20],dep[maxn];
inline void dfs(int u,int pre){
    pl[u]=++tot;
    dep[u]=dep[pre]+1;
    st[u][0]=pre;rep(i,1,20) st[u][i]=st[st[u][i-1]][i-1];
    for(int i=head[u];~i;i=e[i].nxt){
        int v=e[i].u;
        if(v==pre) continue;
        dfs(v,u);
    }
    pr[u]=tot;
}
inline int lca(int u,int v){
    if(u==v) return u;
    if(dep[u]<dep[v]) swap(u,v);
    for(int i=19;i>=0;i--) if(dep[st[u][i]]>=dep[v])
        u=st[u][i];
    if(u==v) return u;
    for(int i=19;i>=0;i--) if(st[u][i]&&st[u][i]!=st[v][i])
        u=st[u][i],v=st[v][i];
    return st[u][0];
}
int dp[maxn];
int k,m,r,a[maxn],f[maxn],vis[maxn];
int main(){
    init();///初始化
    mst(st,0),mst(dep,0);
    scanf("%d%d",&n,&q);
    rep(i,0,n-1){
        scanf("%d%d",&x,&y);
        add(x,y),add(y,x);
    }
    tot=0;dfs(1,0);
    rep(i,0,q){
        mst(vis,0),mst(bit,0);
        scanf("%d%d%d",&k,&m,&r);
        rep(i,1,k+1){
            scanf("%d",&a[i]);
            vis[a[i]]=1;
            refresh(pl[a[i]],1);
            refresh(pr[a[i]]+1,-1);
        }
        rep(i,1,k+1){
            int rt=lca(r,a[i]);
            f[i]=sum(pl[a[i]])+sum(pl[r])-2*sum(pl[rt])+vis[rt]-1;///减去自己
        }
        sort(f+1,f+1+k);
        mst(dp,0),dp[0]=1;
        rep(i,1,k+1) for(int j=m;j>=f[i];j--) dp[j]=dp[j-1]+dp[j]*(j-f[i]);
        ll ans=0;rep(i,f[k],m+1) ans+=dp[i];
        printf("%lld\n",ans);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long
#define mst(a,b) memset((a),(b),sizeof(a))
const int mod=1e9+7;
const int maxn=1e5+5;
const int ub=1e6;
const double inf=1e-4;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
int n,q,x,y;
///前式链向星
struct node{
    int u,nxt;
}e[maxn<<1];
int head[maxn],tot=0;
inline void add(int x,int y){
    e[tot]=node{y,head[x]};
    head[x]=tot++;
}
inline void init(){
    mst(head,-1),tot=0;
}

int pl[maxn],pr[maxn],bit[maxn];///深度
inline void refresh(int x,int d){
    for(;x<maxn;bit[x]+=d,x+=x&-x);
}
inline int sum(int x){
    int ret=0;for(;x>0;ret+=bit[x],x-=x&-x);return ret;
}
int st[maxn][22],dep[maxn];
inline void dfs(int u,int pre){
    pl[u]=++tot;
    dep[u]=dep[pre]+1;
    st[u][0]=pre;rep(i,1,20) st[u][i]=st[st[u][i-1]][i-1];
    for(int i=head[u];~i;i=e[i].nxt){
        int v=e[i].u;
        if(v==pre) continue;
        dfs(v,u);
    }
    pr[u]=tot;
}
inline int lca(int u,int v){
    if(u==v) return u;
    if(dep[u]<dep[v]) swap(u,v);
    for(int i=19;i>=0;i--) if(dep[st[u][i]]>=dep[v])
        u=st[u][i];
    if(u==v) return u;
    for(int i=19;i>=0;i--) if(st[u][i]!=st[v][i])
        u=st[u][i],v=st[v][i];
    return st[u][0];
}
ll dp[maxn];
int k,m,r,a[maxn],f[maxn],vis[maxn];
int main(){
    init();///初始化
    scanf("%d%d",&n,&q);
    rep(i,0,n-1){
        scanf("%d%d",&x,&y);
        add(x,y),add(y,x);
    }
    tot=0;dfs(1,0);
    rep(i,0,q){
        mst(bit,0),mst(vis,0);
        scanf("%d%d%d",&k,&m,&r);
        rep(i,1,k+1){
            scanf("%d",&a[i]);
            vis[a[i]]=1;
            refresh(pl[a[i]],1);
            refresh(pr[a[i]]+1,-1);
        }
        rep(i,1,k+1){
            int LCA=lca(r,a[i]);
            f[i]=sum(pl[a[i]])+sum(pl[r])-2*sum(pl[LCA])+vis[LCA]-1;///减去自己
        }
        if(f[k]>=m) {puts("0");continue;}
        sort(f+1,f+1+k);
        mst(dp,0),dp[0]=1;
        rep(i,1,k+1) for(int j=min(i,m);j>=0;j--){
            if(j<f[i]) dp[j]=0;
            else dp[j]=(dp[j-1]+dp[j]*(j-f[i])%mod)%mod;
        }
        ll ans=0;rep(i,1,m+1) (ans+=dp[i])%=mod;
        cout<<ans<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long
#define mst(a,b) memset((a),(b),sizeof(a))
const int mod=1e9+7;
const int maxn=1e5+5;
const int ub=1e6;
const double inf=1e-4;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
int n,q,x,y;
///前式链向星
struct node{
    int u,nxt;
}e[maxn<<1];
int head[maxn],tot=0;
inline void add(int x,int y){
    e[tot]=node{y,head[x]};
    head[x]=tot++;
}
inline void init(){
    mst(head,-1),tot=0;
}

int pl[maxn],pr[maxn],bit[maxn];///深度
inline void refresh(int x,int d){
    for(;x<maxn;bit[x]+=d,x+=x&-x);
}
inline int sum(int x){
    int ret=0;for(;x>0;ret+=bit[x],x-=x&-x);return ret;
}
int st[maxn][22],dep[maxn];
inline void dfs(int u,int pre){
    pl[u]=++tot;
    dep[u]=dep[pre]+1;
    st[u][0]=pre;rep(i,1,20) st[u][i]=st[st[u][i-1]][i-1];
    for(int i=head[u];~i;i=e[i].nxt){
        int v=e[i].u;
        if(v==pre) continue;
        dfs(v,u);
    }
    pr[u]=tot;
}
inline int lca(int u,int v){
    if(u==v) return u;
    if(dep[u]<dep[v]) swap(u,v);
    for(int i=19;i>=0;i--) if(dep[st[u][i]]>=dep[v])
        u=st[u][i];
    if(u==v) return u;
    for(int i=19;i>=0;i--) if(st[u][i]&&st[u][i]!=st[v][i])
        u=st[u][i],v=st[v][i];
    return st[u][0];
}
int dp[maxn];
int k,m,r,a[maxn],f[maxn],vis[maxn];
int main(){
    init();///初始化
    scanf("%d%d",&n,&q);
    rep(i,0,n-1){
        scanf("%d%d",&x,&y);
        add(x,y),add(y,x);
    }
    tot=0;dfs(1,0);
    rep(i,0,q){
        mst(bit,0),mst(vis,0);
        scanf("%d%d%d",&k,&m,&r);
        rep(i,1,k+1){
            scanf("%d",&a[i]);
            vis[a[i]]=1;
            refresh(pl[a[i]],1);
            refresh(pr[a[i]]+1,-1);
        }
        rep(i,1,k+1){
            int LCA=lca(r,a[i]);
            f[i]=sum(pl[a[i]])+sum(pl[r])-2*sum(pl[LCA])+vis[LCA]-1;///减去自己
        }
        sort(f+1,f+1+k);
        mst(dp,0),dp[0]=1;
        rep(i,1,k+1) for(int j=min(i,m);j>=f[i];j--) dp[j]=dp[j-1]+dp[j]*(j-f[i]);
        ll ans=0;rep(i,1,m+1) ans+=dp[i];
        cout<<ans<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long
#define mst(a,b) memset((a),(b),sizeof(a))
const int mod=1e9+7;
const int maxn=1e5+5;
const int ub=1e6;
const double inf=1e-4;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
int n,q,x,y;
///前式链向星
struct node{
    int u,nxt;
}e[maxn<<1];
int head[maxn],tot=0;
inline void add(int x,int y){
    e[tot]=node{y,head[x]};
    head[x]=tot++;
}
inline void init(){
    mst(head,-1),tot=0;
}

int pl[maxn],pr[maxn],bit[maxn];///深度
inline void refresh(int x,int d){
    for(;x<maxn;bit[x]+=d,x+=x&-x);
}
inline int sum(int x){
    int ret=0;for(;x>0;ret+=bit[x],x-=x&-x);return ret;
}
int st[maxn][22],dep[maxn];
inline void dfs(int u,int pre){
    pl[u]=++tot;
    dep[u]=dep[pre]+1;
    st[u][0]=pre;rep(i,1,20) st[u][i]=st[st[u][i-1]][i-1];
    for(int i=head[u];~i;i=e[i].nxt){
        int v=e[i].u;
        if(v==pre) continue;
        dfs(v,u);
    }
    pr[u]=tot;
}
inline int lca(int u,int v){
    if(u==v) return u;
    if(dep[u]<dep[v]) swap(u,v);
    for(int i=19;i>=0;i--) if(dep[st[u][i]]>=dep[v])
        u=st[u][i];
    if(u==v) return u;
    for(int i=19;i>=0;i--) if(st[u][i]!=st[v][i])
        u=st[u][i],v=st[v][i];
    return st[u][0];
}
ll dp[maxn];
int k,m,r,a[maxn],f[maxn],vis[maxn];
int main(){
    init();///初始化
    scanf("%d%d",&n,&q);
    rep(i,0,n-1){
        scanf("%d%d",&x,&y);
        add(x,y),add(y,x);
    }
    tot=0;dfs(1,0);
    rep(i,0,q){
        mst(bit,0),mst(vis,0);
        scanf("%d%d%d",&k,&m,&r);
        rep(i,1,k+1){
            scanf("%d",&a[i]);
            vis[a[i]]=1;
            refresh(pl[a[i]],1);
            refresh(pr[a[i]]+1,-1);
        }
        rep(i,1,k+1){
            int LCA=lca(r,a[i]);
            f[i]=sum(pl[a[i]])+sum(pl[r])-2*sum(pl[LCA])+vis[LCA]-1;///减去自己
        }
        if(f[k]>=m) {puts("0");continue;}
        sort(f+1,f+1+k);
        mst(dp,0),dp[0]=1;
        rep(i,1,k+1) for(int j=min(i,m);j>=1;j--){
            if(j<f[i]) dp[j]=0;
            else dp[j]=(dp[j-1]+dp[j]*(j-f[i])%mod)%mod;
        }
        ll ans=0;rep(i,1,m+1) (ans+=dp[i])%=mod;
        cout<<ans<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long
#define mst(a,b) memset((a),(b),sizeof(a))
const int mod=1e9+7;
const int maxn=1e5+5;
const int ub=1e6;
const double inf=1e-4;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
int n,q,x,y;
///前式链向星
struct node{
    int u,nxt;
}e[maxn<<1];
int head[maxn],tot=0;
inline void add(int x,int y){
    e[tot]=node{y,head[x]};
    head[x]=tot++;
}
inline void init(){
    mst(head,-1),tot=0;
}

int pl[maxn],pr[maxn],bit[maxn];///深度
inline void refresh(int x,int d){
    for(;x<maxn;bit[x]+=d,x+=x&-x);
}
inline int sum(int x){
    int ret=0;for(;x>0;ret+=bit[x],x-=x&-x);return ret;
}
int st[maxn][22],dep[maxn];
inline void dfs(int u,int pre){
    pl[u]=++tot;
    dep[u]=dep[pre]+1;
    st[u][0]=pre;rep(i,1,19) st[u][i]=st[st[u][i-1]][i-1];
    for(int i=head[u];~i;i=e[i].nxt){
        int v=e[i].u;
        if(v==pre) continue;
        dfs(v,u);
    }
    pr[u]=tot;
}
inline int lca(int u,int v){
    if(u==v) return u;
    if(dep[u]<dep[v]) swap(u,v);
    for(int i=18;i>=0;i--) if(dep[st[u][i]]>=dep[v])
        u=st[u][i];
    if(u==v) return u;
    for(int i=18;i>=0;i--) if(st[u][i]!=st[v][i])
        u=st[u][i],v=st[v][i];
    return st[u][0];
}
ll dp[maxn];
int k,m,r,a[maxn],f[maxn],vis[maxn];
int main(){
    init();///初始化
    scanf("%d%d",&n,&q);
    rep(i,0,n-1){
        scanf("%d%d",&x,&y);
        add(x,y),add(y,x);
    }
    tot=0;dfs(1,0);
    rep(i,0,q){
        scanf("%d%d%d",&k,&m,&r);
        rep(i,1,k+1){
            scanf("%d",&a[i]);
            vis[a[i]]=1;
            refresh(pl[a[i]],1);
            refresh(pr[a[i]]+1,-1);
        }
        int tmp=sum(pl[r]);
        rep(i,1,k+1){
            int LCA=lca(r,a[i]);
            f[i]=sum(pl[a[i]])+tmp-2*sum(pl[LCA])+vis[LCA]-1;///减去自己
        }
        rep(i,1,k+1){
            vis[a[i]]=0;
            refresh(pl[a[i]],-1);
            refresh(pr[a[i]]+1,1);
        }
        if(f[k]>=m) {puts("0");continue;}
        sort(f+1,f+1+k);
        mst(dp,0),dp[0]=1;
        rep(i,1,k+1) for(int j=min(i,m);j>=0;j--){
            if(j<=f[i]) dp[j]=0;
            else dp[j]=(dp[j-1]+dp[j]*(j-f[i])%mod)%mod;
        }
        ll ans=0;rep(i,1,m+1) (ans+=dp[i])%=mod;
        printf("%lld\n",ans);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define debug puts("YES");
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long

#define lrt int l,int r,int rt
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define root l,r,rt
#define mst(a,b) memset((a),(b),sizeof(a))
#define pii pair<int,int>
#define fi first
#define se second
#define mk(x,y) make_pair(x,y)
const int mod=1e9+7;
const int maxn=1e5+5;
const int ub=1e6;
const double inf=1e-4;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
int n,q,x,y;
///前式链向星
struct node{
    int u,nxt;
}e[maxn<<1];
int head[maxn],tot=0;
void add(int x,int y){
    e[tot]=node{y,head[x]};
    head[x]=tot++;
}
void init(){
    mst(head,-1),tot=0;
}

int pl[maxn],pr[maxn],bit[maxn];///深度
void refresh(int x,int d){
    for(;x<maxn;bit[x]+=d,x+=x&-x);
}
int sum(int x){
    int ret=0;for(;x>0;ret+=bit[x],x-=x&-x);return ret;
}
int st[maxn][20],dep[maxn];
void dfs(int u,int pre){
    pl[u]=++tot;
    dep[u]=dep[pre]+1;
    st[u][0]=pre;rep(i,1,20) st[u][i]=st[st[u][i-1]][i-1];
    for(int i=head[u];~i;i=e[i].nxt){
        int v=e[i].u;
        if(v==pre) continue;
        dfs(v,u);
    }
    pr[u]=tot;
}
int lca(int u,int v){
    if(dep[u]<dep[v]) swap(u,v);
    for(int i=19;i>=0;i--) if(dep[st[u][i]]>=dep[v])
        u=st[u][i];
    if(u==v) return u;
    for(int i=19;i>=0;i--) if(st[u][i]&&st[u][i]!=st[v][i])
        u=st[u][i],v=st[v][i];
    return st[u][0];
}
int dp[maxn][305];
int k,m,r,a[maxn],f[maxn],vis[maxn];
int main(){
    init();///初始化
    mst(st,0),mst(dep,0);
    scanf("%d%d",&n,&q);
    rep(i,0,n-1){
        scanf("%d%d",&x,&y);
        add(x,y),add(y,x);
    }
    tot=0;dfs(1,0);
    rep(i,0,q){
        mst(vis,0),mst(bit,0);
        scanf("%d%d%d",&k,&m,&r);
        rep(i,1,k+1){
            scanf("%d",&a[i]);
            vis[a[i]]=1;
            refresh(pl[a[i]],1);
            refresh(pr[a[i]]+1,-1);
        }
        rep(i,1,k+1){
            int rt=lca(r,a[i]);
            f[i]=sum(pl[a[i]])+sum(pl[r])-2*sum(pl[rt])+vis[rt]-1;///减去自己
        }
        sort(f+1,f+1+k);
        mst(dp,0),dp[0][0]=1;
        rep(i,1,k+1) rep(j,f[i],m+1) dp[i][j]=dp[i-1][j-1]+dp[i-1][j]*(j-f[i]);
        ///rep(i,1,m+1) dp[k][i]+=dp[k][i-1];
        int ans=0;rep(i,1,m+1) ans+=dp[k][i];
        printf("%d\n",ans);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long
#define mst(a,b) memset((a),(b),sizeof(a))
const int mod=1e9+7;
const int maxn=1e5+10;
const int ub=1e6;
const double inf=1e-4;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
int n,q,x,y;
///前式链向星
vector<int> g[maxn];
int pl[maxn],pr[maxn],bit[maxn],tot;///深度
inline void refresh(int x,int d){
    for(;x<maxn;bit[x]+=d,x+=x&-x);
}
inline int sum(int x){
    int ret=0;for(;x;ret+=bit[x],x-=x&-x);return ret;
}
int st[maxn][20],dep[maxn];
inline void dfs(int u,int pre){
    pl[u]=++tot;
    dep[u]=dep[pre]+1;
    st[u][0]=pre;
    for(int i=0;i<g[u].size();i++){
        int v=g[u][i];
        if(v==pre) continue;
        dfs(v,u);
    }
    pr[u]=tot;
}
inline int lca(int u,int v){
    if(u==v) return u;
    if(dep[u]<dep[v]) swap(u,v);
    for(int i=19;i>=0;i--) if(dep[st[u][i]]>=dep[v])
        u=st[u][i];
    if(u==v) return u;
    for(int i=19;i>=0;i--) if(st[u][i]!=st[v][i])
        u=st[u][i],v=st[v][i];
    return st[u][0];
}
int dp[maxn];
int k,m,r,a[maxn],f[maxn],vis[maxn];
int main(){
    scanf("%d%d",&n,&q);
    rep(i,0,n-1){
        scanf("%d%d",&x,&y);
        g[x].push_back(y);
        g[y].push_back(x);
    }
    tot=0;dfs(1,0);
    rep(i,1,k+1) rep(j,1,20) st[i][j]=st[st[i][j-1]][j-1];
    rep(i,0,q){
        scanf("%d%d%d",&k,&m,&r);
        rep(i,1,k+1){
            scanf("%d",&a[i]);
            vis[a[i]]=1;
            refresh(pl[a[i]],1);
            refresh(pr[a[i]]+1,-1);
        }
        int tmp=sum(pl[r]);
        rep(i,1,k+1){
            int LCA=lca(r,a[i]);
            f[i]=sum(pl[a[i]])+tmp-2*sum(pl[LCA])+vis[LCA]-1;///减去自己
        }
        rep(i,1,k+1){
            vis[a[i]]=0;
            refresh(pl[a[i]],-1);
            refresh(pr[a[i]]+1,1);
        }
        if(f[k]>=m) {puts("0");continue;}
        sort(f+1,f+1+k);
        mst(dp,0),dp[0]=1;
        rep(i,1,k+1) for(int j=min(i,m);j>=0;j--){
            if(j<=f[i]) dp[j]=0;
            else dp[j]=((ll)dp[j-1]+(ll)dp[j]*(j-f[i])%mod)%mod;
        }
        ll ans=0;rep(i,1,m+1) (ans+=dp[i])%=mod;
        printf("%lld\n",ans);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long
#define mst(a,b) memset((a),(b),sizeof(a))
const int mod=1e9+7;
const int maxn=1e5+5;
const int ub=1e6;
const double inf=1e-4;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
int n,q,x,y;
///前式链向星
struct node{
    int u,nxt;
}e[maxn<<1];
int head[maxn],tot=0;
inline void add(int x,int y){
    e[tot]=node{y,head[x]};
    head[x]=tot++;
}
inline void init(){
    mst(head,-1),tot=0;
}

int pl[maxn],pr[maxn],bit[maxn];///深度
inline void refresh(int x,int d){
    for(;x<maxn;bit[x]+=d,x+=x&-x);
}
inline int sum(int x){
    int ret=0;for(;x>0;ret+=bit[x],x-=x&-x);return ret;
}
int st[maxn][22],dep[maxn];
inline void dfs(int u,int pre){
    pl[u]=++tot;
    dep[u]=dep[pre]+1;
    st[u][0]=pre;rep(i,1,20) st[u][i]=st[st[u][i-1]][i-1];
    for(int i=head[u];~i;i=e[i].nxt){
        int v=e[i].u;
        if(v==pre) continue;
        dfs(v,u);
    }
    pr[u]=tot;
}
inline int lca(int u,int v){
    if(u==v) return u;
    if(dep[u]<dep[v]) swap(u,v);
    for(int i=19;i>=0;i--) if(dep[st[u][i]]>=dep[v])
        u=st[u][i];
    if(u==v) return u;
    for(int i=19;i>=0;i--) if(st[u][i]!=st[v][i])
        u=st[u][i],v=st[v][i];
    return st[u][0];
}
ll dp[maxn];
int k,m,r,a[maxn],f[maxn],vis[maxn];
int main(){
    init();///初始化
    scanf("%d%d",&n,&q);
    rep(i,0,n-1){
        scanf("%d%d",&x,&y);
        add(x,y),add(y,x);
    }
    tot=0;dfs(1,0);
    rep(i,0,q){
        mst(bit,0),mst(vis,0);
        scanf("%d%d%d",&k,&m,&r);
        rep(i,1,k+1){
            scanf("%d",&a[i]);
            vis[a[i]]=1;
            refresh(pl[a[i]],1);
            refresh(pr[a[i]]+1,-1);
        }
        rep(i,1,k+1){
            int LCA=lca(r,a[i]);
            f[i]=sum(pl[a[i]])+sum(pl[r])-2*sum(pl[LCA])+vis[LCA]-1;///减去自己
        }
        sort(f+1,f+1+k);
        mst(dp,0),dp[0]=1;
        rep(i,1,k+1) for(int j=min(i,m);j>=f[i];j--) dp[j]=(dp[j-1]+dp[j]*(j-f[i])%mod)%mod;
        ll ans=0;rep(i,1,m+1) (ans+=dp[i])%=mod;
        cout<<ans<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long
#define mst(a,b) memset((a),(b),sizeof(a))
const int mod=1e9+7;
const int maxn=1e5+10;
const int ub=1e6;
const double inf=1e-4;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
int n,q,x,y;
///前式链向星
vector<int> g[maxn];
int pl[maxn],pr[maxn],bit[maxn],tot;///深度
inline void refresh(int x,int d){
    for(;x<maxn;bit[x]+=d,x+=x&-x);
}
inline int sum(int x){
    int ret=0;for(;x;ret+=bit[x],x-=x&-x);return ret;
}
int st[maxn][20],dep[maxn];
inline void dfs(int u,int pre){
    pl[u]=++tot;
    dep[u]=dep[pre]+1;
    st[u][0]=pre;rep(i,1,20) st[u][i]=st[st[u][i-1]][i-1];
    for(int i=0;i<g[u].size();i++){
        int v=g[u][i];
        if(v==pre) continue;
        dfs(v,u);
    }
    pr[u]=tot;
}
inline int lca(int u,int v){
    if(u==v) return u;
    if(dep[u]<dep[v]) swap(u,v);
    for(int i=19;i>=0;i--) if(dep[st[u][i]]>=dep[v])
        u=st[u][i];
    if(u==v) return u;
    for(int i=19;i>=0;i--) if(st[u][i]!=st[v][i])
        u=st[u][i],v=st[v][i];
    return st[u][0];
}
int dp[maxn];
int k,m,r,a[maxn],f[maxn],vis[maxn];
int main(){
    scanf("%d%d",&n,&q);
    rep(i,0,n-1){
        scanf("%d%d",&x,&y);
        g[x].push_back(y);
        g[y].push_back(x);
    }
    tot=0;dfs(1,0);
    ///cout<<lca(6,3)<<endl;
    rep(i,0,q){
        scanf("%d%d%d",&k,&m,&r);
        rep(i,1,k+1){
            scanf("%d",&a[i]);
            vis[a[i]]=1;
            refresh(pl[a[i]],1);
            refresh(pr[a[i]]+1,-1);
        }
        int tmp=sum(pl[r]);
        rep(i,1,k+1){
            int LCA=lca(r,a[i]);
            f[i]=sum(pl[a[i]])+tmp-2*sum(pl[LCA])+vis[LCA]-1;///减去自己
        }
        rep(i,1,k+1){
            vis[a[i]]=0;
            refresh(pl[a[i]],-1);
            refresh(pr[a[i]]+1,1);
        }
        if(f[k]>=m) {puts("0");continue;}
        sort(f+1,f+1+k);
        mst(dp,0),dp[0]=1;
        rep(i,1,k+1) for(int j=min(i,m);j>=0;j--){
            if(j<=f[i]) dp[j]=0;
            else dp[j]=((ll)dp[j-1]+(ll)dp[j]*(j-f[i])%mod)%mod;
        }
        ll ans=0;rep(i,1,m+1) (ans+=dp[i])%=mod;
        printf("%lld\n",ans);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long
#define mst(a,b) memset((a),(b),sizeof(a))
const int mod=1e9+7;
const int maxn=1e5+5;
const int ub=1e6;
const double inf=1e-4;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
int n,q,x,y;
///前式链向星
struct node{
    int u,nxt;
}e[maxn<<1];
int head[maxn],tot=0;
inline void add(int x,int y){
    e[tot]=node{y,head[x]};
    head[x]=tot++;
}
inline void init(){
    mst(head,-1),tot=0;
}

int pl[maxn],pr[maxn],bit[maxn];///深度
inline void refresh(int x,int d){
    for(;x<maxn;bit[x]+=d,x+=x&-x);
}
inline int sum(int x){
    int ret=0;for(;x>0;ret+=bit[x],x-=x&-x);return ret;
}
int st[maxn][22],dep[maxn];
inline void dfs(int u,int pre){
    pl[u]=++tot;
    dep[u]=dep[pre]+1;
    st[u][0]=pre;rep(i,1,20) st[u][i]=st[st[u][i-1]][i-1];
    for(int i=head[u];~i;i=e[i].nxt){
        int v=e[i].u;
        if(v==pre) continue;
        dfs(v,u);
    }
    pr[u]=tot;
}
inline int lca(int u,int v){
    if(u==v) return u;
    if(dep[u]<dep[v]) swap(u,v);
    for(int i=19;i>=0;i--) if(dep[st[u][i]]>=dep[v])
        u=st[u][i];
    if(u==v) return u;
    for(int i=19;i>=0;i--) if(st[u][i]&&st[u][i]!=st[v][i])
        u=st[u][i],v=st[v][i];
    return st[u][0];
}
int dp[maxn];
int k,m,r,a[maxn],f[maxn],vis[maxn];
int main(){
    init();///初始化
    mst(st,0),mst(dep,0);
    scanf("%d%d",&n,&q);
    rep(i,0,n-1){
        scanf("%d%d",&x,&y);
        add(x,y),add(y,x);
    }
    tot=0;dfs(1,0);
    rep(i,0,q){
        mst(bit,0),mst(vis,0);
        scanf("%d%d%d",&k,&m,&r);
        rep(i,1,k+1){
            scanf("%d",&a[i]);
            vis[a[i]]=1;
            refresh(pl[a[i]],1);
            refresh(pr[a[i]]+1,-1);
        }
        rep(i,1,k+1){
            int LCA=lca(r,a[i]);
            f[i]=sum(pl[a[i]])+sum(pl[r])-2*sum(pl[LCA])+vis[LCA]-1;///减去自己
        }
        sort(f+1,f+1+k);
        mst(dp,0),dp[0]=1;
        rep(i,1,k+1) for(int j=m;j>=f[i];j--) dp[j]=dp[j-1]+dp[j]*(j-f[i]);
        ll ans=0;rep(i,1,m+1) ans+=dp[i];
        cout<<ans<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long
#define mst(a,b) memset((a),(b),sizeof(a))
const int mod=1e9+7;
const int maxn=1e5+5;
const int ub=1e6;
const double inf=1e-4;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
int n,q,x,y;
///前式链向星
vector<int> g[maxn];

int pl[maxn],pr[maxn],bit[maxn],tot;///深度
inline void refresh(int x,int d){
    for(;x<maxn;bit[x]+=d,x+=x&-x);
}
inline int sum(int x){
    int ret=0;for(;x>0;ret+=bit[x],x-=x&-x);return ret;
}
int st[maxn][22],dep[maxn];
inline void dfs(int u,int pre){
    pl[u]=++tot;
    dep[u]=dep[pre]+1;
    st[u][0]=pre;rep(i,1,19) st[u][i]=st[st[u][i-1]][i-1];
    for(int i=0;i<g[u].size();i++){
        int v=g[u][i];
        if(v==pre) continue;
        dfs(v,u);
    }
    pr[u]=tot;
}
inline int lca(int u,int v){
    if(u==v) return u;
    if(dep[u]<dep[v]) swap(u,v);
    for(int i=18;i>=0;i--) if(dep[st[u][i]]>=dep[v])
        u=st[u][i];
    if(u==v) return u;
    for(int i=18;i>=0;i--) if(st[u][i]!=st[v][i])
        u=st[u][i],v=st[v][i];
    return st[u][0];
}
ll dp[maxn];
int k,m,r,a[maxn],f[maxn],vis[maxn];
int main(){
    scanf("%d%d",&n,&q);
    rep(i,0,n-1){
        scanf("%d%d",&x,&y);
        g[x].push_back(y);
        g[y].push_back(x);
    }
    tot=0;dfs(1,0);
    rep(i,0,q){
        scanf("%d%d%d",&k,&m,&r);
        rep(i,1,k+1){
            scanf("%d",&a[i]);
            vis[a[i]]=1;
            refresh(pl[a[i]],1);
            refresh(pr[a[i]]+1,-1);
        }
        int tmp=sum(pl[r]);
        rep(i,1,k+1){
            int LCA=lca(r,a[i]);
            f[i]=sum(pl[a[i]])+tmp-2*sum(pl[LCA])+vis[LCA]-1;///减去自己
        }
        rep(i,1,k+1){
            vis[a[i]]=0;
            refresh(pl[a[i]],-1);
            refresh(pr[a[i]]+1,1);
        }
        if(f[k]>=m) {puts("0");continue;}
        sort(f+1,f+1+k);
        mst(dp,0),dp[0]=1;
        rep(i,1,k+1) for(int j=min(i,m);j>=0;j--){
            if(j<=f[i]) dp[j]=0;
            else dp[j]=(dp[j-1]+dp[j]*(j-f[i])%mod)%mod;
        }
        ll ans=0;rep(i,1,m+1) (ans+=dp[i])%=mod;
        printf("%lld\n",ans);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long
#define mst(a,b) memset((a),(b),sizeof(a))
const int mod=1e9+7;
const int maxn=1e5+10;
const int ub=1e6;
const double inf=1e-4;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
int n,q,x,y;
///前式链向星
vector<int> g[maxn];
int pl[maxn],pr[maxn],bit[maxn],tot;///深度
inline void refresh(int x,int d){
    for(;x<maxn;bit[x]+=d,x+=x&-x);
}
inline int sum(int x){
    int ret=0;for(;x;ret+=bit[x],x-=x&-x);return ret;
}
int st[maxn][20],dep[maxn];
inline void dfs(int u,int pre){
    pl[u]=++tot;
    dep[u]=dep[pre]+1;
    st[u][0]=pre;
    for(int i=0;i<g[u].size();i++){
        int v=g[u][i];
        if(v==pre) continue;
        dfs(v,u);
    }
    pr[u]=tot;
}
inline int lca(int u,int v){
    if(u==v) return u;
    if(dep[u]<dep[v]) swap(u,v);
    for(int i=19;i>=0;i--) if(dep[st[u][i]]>=dep[v])
        u=st[u][i];
    if(u==v) return u;
    for(int i=19;i>=0;i--) if(st[u][i]!=st[v][i])
        u=st[u][i],v=st[v][i];
    return st[u][0];
}
int dp[maxn];
int k,m,r,a[maxn],f[maxn],vis[maxn];
int main(){
    scanf("%d%d",&n,&q);
    rep(i,0,n-1){
        scanf("%d%d",&x,&y);
        g[x].push_back(y);
        g[y].push_back(x);
    }
    tot=0;dfs(1,0);
    rep(i,1,k+1) rep(j,1,20) st[i][j]=st[st[i][j-1]][j-1];
    rep(i,0,q){
        scanf("%d%d%d",&k,&m,&r);
        rep(i,1,k+1){
            scanf("%d",&a[i]);
            vis[a[i]]=1;
            refresh(pl[a[i]],1);
            refresh(pr[a[i]]+1,-1);
        }
        int tmp=sum(pl[r]);
        rep(i,1,k+1){
            int LCA=lca(r,a[i]);
            f[i]=sum(pl[a[i]])+tmp-2*sum(pl[LCA])+vis[LCA]-1;///减去自己
        }
        rep(i,1,k+1){
            vis[a[i]]=0;
            refresh(pl[a[i]],-1);
            refresh(pr[a[i]]+1,1);
        }
        if(f[k]>=m) {puts("0");continue;}
        sort(f+1,f+1+k);
        mst(dp,0),dp[0]=1;
        rep(i,1,k+1) for(int j=min(i,m);j>=0;j--){
            if(j<=f[i]) dp[j]=0;
            else dp[j]=((LL)dp[j-1]+(LL)dp[j]*(j-f[i])%mod)%mod;
        }
        ll ans=0;rep(i,1,m+1) (ans+=dp[i])%=mod;
        printf("%lld\n",ans);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define debug puts("YES");
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long

#define lrt int l,int r,int rt
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define root l,r,rt
#define mst(a,b) memset((a),(b),sizeof(a))
#define pii pair<int,int>
#define fi first
#define se second
#define mk(x,y) make_pair(x,y)
const int mod=1e9+7;
const int maxn=1e5+5;
const int ub=1e6;
const double inf=1e-4;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
int n,q,x,y;
///前式链向星
struct node{
    int u,nxt;
}e[maxn<<1];
int head[maxn],tot=0;
void add(int x,int y){
    e[tot]=node{y,head[x]};
    head[x]=tot++;
}
void init(){
    mst(head,-1),tot=0;
}

int pl[maxn],pr[maxn],bit[maxn];///深度
void refresh(int x,int d){
    for(;x<maxn;bit[x]+=d,x+=x&-x);
}
int sum(int x){
    int ret=0;for(;x>0;ret+=bit[x],x-=x&-x);return ret;
}
int st[maxn][20],dep[maxn];
void dfs(int u,int pre){
    pl[u]=++tot;
    dep[u]=dep[pre]+1;
    st[u][0]=pre;rep(i,1,20) st[u][i]=st[st[u][i-1]][i-1];
    for(int i=head[u];~i;i=e[i].nxt){
        int v=e[i].u;
        if(v==pre) continue;
        dfs(v,u);
    }
    pr[u]=tot;
}
int lca(int u,int v){
    if(dep[u]<dep[v]) swap(u,v);
    for(int i=19;i>=0;i--) if(dep[st[u][i]]>=dep[v])
        u=st[u][i];
    if(u==v) return u;
    for(int i=19;i>=0;i--) if(st[u][i]&&st[u][i]!=st[v][i])
        u=st[u][i],v=st[v][i];
    return st[u][0];
}
int dp[maxn][305];
int k,m,r,a[maxn],f[maxn],vis[maxn];
int main(){
    init();///初始化
    scanf("%d%d",&n,&q);
    rep(i,0,n-1){
        scanf("%d%d",&x,&y);
        add(x,y),add(y,x);
    }
    tot=0;dfs(1,0);
    rep(i,0,q){
        mst(vis,0),mst(bit,0);
        scanf("%d%d%d",&k,&m,&r);
        rep(i,1,k+1){
            scanf("%d",&a[i]);
            vis[a[i]]=1;
            refresh(pl[a[i]],1);
            refresh(pr[a[i]]+1,-1);
        }
        rep(i,1,k+1){
            int rt=lca(r,a[i]);
            f[i]=sum(pl[a[i]])+sum(pl[r])-2*sum(pl[rt])+vis[rt]-1;///减去自己
        }
        sort(f+1,f+1+k);
        mst(dp,0),dp[0][0]=1;
        rep(i,1,k+1) rep(j,f[i],m+1) dp[i][j]=dp[i-1][j-1]+dp[i-1][j]*(j-f[i]);
        ///rep(i,1,m+1) dp[k][i]+=dp[k][i-1];
        int ans=0;rep(i,1,m+1) ans+=dp[k][i];
        printf("%d\n",ans);
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int cys=1000000007;
int n,m,q,k,r,tot,ncnt;
int siz[100005],dep[100005],top[100005],v[200005],nxt[200005],h[100005],dfn[100005],f[100005],son[100005],a[100005],faa[100005];
ll d[100005][305];

namespace seg{
	int sum[300000];
	void change(int id,int l,int r,int p,int c){
		if(l==r) return (void)(sum[id]+=c);
		int mid=(l+r)/2;
		if(p<=mid) change(id<<1,l,mid,p,c);
		else change(id<<1|1,mid+1,r,p,c);
		sum[id]=sum[id<<1]+sum[id<<1|1];
	}
	int query(int id,int l,int r,int ql,int qr){
		if(l==ql&&r==qr) return sum[id];
		int mid=(l+r)/2;
		if(qr<=mid) return query(id<<1,l,mid,ql,qr);
		else if(ql>mid) return query(id<<1|1,mid+1,r,ql,qr);
		else return query(id<<1,l,mid,ql,mid)+query(id<<1|1,mid+1,r,mid+1,qr);
	}
}

int mod(int x){return x>=cys?x-cys:x;}

void addedge(int x,int y){
	v[++tot]=y; nxt[tot]=h[x]; h[x]=tot;
	v[++tot]=x; nxt[tot]=h[y]; h[y]=tot;
}

void dfs1(int u,int fa){
	siz[u]=1;
	for(int p=h[u];p;p=nxt[p]){
		if(v[p]==fa) continue;
		dep[v[p]]=dep[u]+1,faa[v[p]]=u;
		dfs1(v[p],u);
		siz[u]+=siz[v[p]];
		if(siz[v[p]]>siz[son[u]]) son[u]=v[p];
	}
}

void dfs2(int u,int fa){
	dfn[u]=++ncnt;
	if(son[u]){
		top[son[u]]=top[u];
		dfs2(son[u],u);
	}
	for(int p=h[u];p;p=nxt[p]){
		if(v[p]==fa||v[p]==son[u]) continue;
		top[v[p]]=v[p];
		dfs2(v[p],u);
	}
}

int qlist(int x,int y){
	int ret=0;
	while(top[x]!=top[y]){
		if(dep[top[x]]<dep[top[y]]) swap(x,y);
		ret+=seg::query(1,1,n,dfn[top[x]],dfn[x]);
		x=faa[top[x]];
	}
	if(dfn[x]>dfn[y]) swap(x,y);
	return ret+seg::query(1,1,n,dfn[x],dfn[y]);
}

int main(){
	n=readint(); q=readint();
	for(int i=1;i<=n-1;i++) addedge(readint(),readint());
	dep[1]=1; dfs1(1,-1);
	top[1]=1; dfs2(1,-1);
	while(q--){
		k=readint(); m=readint(); r=readint();
		for(int i=1;i<=k;i++) a[i]=readint();
		for(int i=1;i<=k;i++) seg::change(1,1,n,dfn[a[i]],1);
		for(int i=1;i<=k;i++) f[a[i]]=qlist(r,a[i])-1;
		sort(a+1,a+k+1,[&](int x,int y){return f[x]<f[y];});
		d[0][0]=1;
		for(int i=1;i<=k;i++) for(int j=1;j<=m;j++) d[i][j]=mod(d[i-1][j-1]+(j-f[a[i]])*d[i-1][j]%cys);
		for(int i=1;i<=k;i++) seg::change(1,1,n,dfn[a[i]],-1);
		ll ans=0;
		for(int i=1;i<=m;i++) ans=mod(ans+d[k][i]);
		printf("%lld\n",ans);
	}
	return 0;
}


#include <algorithm>
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
typedef long long llong;
const int maxN = 100'001;
const long long mod = 1000'000'007;
#define assert(X) if (!(bool)(X)) { throw; }

int dp[maxN][301];
int h[maxN];
bool is[maxN];
int dist[maxN];

int l[maxN], r[maxN];
vector<int> nei[maxN];
const int lg = 16;
int par[maxN][lg + 1];
void DFS(int v, int p)
{
    static int time = 0;
    l[v] = ++time;
    par[v][0] = p;
    for (int i = 1; i <= lg; ++i)
        if (par[v][i - 1] != -1)
            par[v][i] = par[par[v][i - 1]][i - 1];
        else
            par[v][i] = -1;
    for (int to: nei[v])
        if (to != p)
            DFS(to, v);
    r[v] = time;
}
inline bool Upper(int u, int v)
{
    return l[u] <= l[v] && r[u] >= r[v];
}
int LCA(int u, int v)
{
    if (Upper(u, v)) return u;
    if (Upper(v, u)) return v;
    for (int i = lg; i >= 0; --i)
        if (par[u][i] != -1 && !Upper(par[u][i], v))
            u = par[u][i];
    return par[u][0];
}
int Dist(int u, int v)
{
    int res = 0;
    for (int i = lg; i >= 0; --i)
        if (par[u][i] != -1 && !Upper(par[u][i], v))
        {
            res += (1 << i);
            u = par[u][i];
        }
    if (!Upper(u, v))
    {
        ++res;
        u = par[u][0];
    }
    for (int i = lg; i >= 0; --i)
        if (par[v][i] != -1 && !Upper(par[v][i], u))
        {
            res += (1 << i);
            v = par[v][i];
        }
    if (!Upper(v, u))
        ++res;
    return res;
}

vector<int> chng;
int lazy[4 * maxN];
void Add(int v, int vl, int vr, int l, int r, int val)
{
    if (r < vl || vr < l)
        return;
    if (l <= vl && vr <= r)
    {
        chng.push_back(v);
        lazy[v] += val;
        return;
    }
    int vm = (vl + vr) / 2;
    Add(v * 2, vl, vm, l, r, val);
    Add(v * 2 + 1, vm + 1, vr, l, r, val);
}
int Get(int v, int vl, int vr, int i)
{
    if (vl == vr)
        return lazy[v];
    int vm = (vl + vr) / 2;
    if (i <= vm)
        return Get(v * 2, vl, vm, i) + lazy[v];
    return Get(v * 2 + 1, vm + 1, vr, i) + lazy[v];
}
int main()
{
    /*ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);*/
    int n, q;
    // cin >> n >> q;
    scanf("%d%d", &n, &q);
    for (int i = 1; i < n; ++i)
    {
        int u, v;
        // cin >> u >> v;
        scanf("%d%d", &u, &v);
        nei[u].push_back(v);
        nei[v].push_back(u);
    }
    DFS(1, -1);
    while (q--)
    {
        int k, m, root;
        // cin >> k >> m >> root;
        scanf("%d%d%d", &k, &m, &root);
        vector<int> a(k);
        for (int& v: a)
        {
            // cin >> v;
            scanf("%d", &v);
            is[v] = true;
            Add(1, 1, n, l[v], r[v], 1);
        }
        for (int v: a)
            dist[v] = Dist(root, v);
        sort(a.begin(), a.end(), [](int u, int v) {
             return dist[u] < dist[v];
        });
        for (int v: a)
        {
            int lca = LCA(v, root);
            h[v] = Get(1, 1, n, l[v]) - 1 + Get(1, 1, n, l[root]) - 2 * Get(1, 1, n, l[lca]) + is[lca];
        }
        dp[0][1] = 1;
        for (int i = 1; i < k; ++i)
            for (int j = 1; j <= m; ++j)
                dp[i][j] = (dp[i - 1][j - 1] + (long long)dp[i - 1][j] * (j - h[a[i]])) % mod;
        int ans = 0;
        for (int j = 1; j <= m; ++j)
            ans = (ans + dp[k - 1][j]) % mod;
        // cout << ans << '\n';
        printf("%d\n", ans);
        for (int v: a)
            is[v] = false;
        for (int i = 0; i < k; ++i)
            for (int j = 1; j <= m; ++j)
                dp[i][j] = 0;
        for (int v: chng)
            lazy[v] = 0;
    }
}


#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long llong;
const int maxN = 100'001;
const long long mod = 1000'000'007;

int dp[maxN][301];
int h[maxN];
bool is[maxN];
int dist[maxN];

int l[maxN], r[maxN];
vector<int> nei[maxN];
const int lg = 16;
int par[maxN][lg + 1];
void DFS(int v, int p)
{
    static int time = 0;
    l[v] = ++time;
    par[v][0] = p;
    for (int i = 1; i <= lg; ++i)
        if (par[v][i - 1] != -1)
            par[v][i] = par[par[v][i - 1]][i - 1];
        else
            par[v][i] = -1;
    for (int to: nei[v])
        if (to != p)
            DFS(to, v);
    r[v] = time;
}
inline bool Upper(int u, int v)
{
    return l[u] <= l[v] && r[u] >= r[v];
}
int LCA(int u, int v)
{
    if (Upper(u, v)) return u;
    if (Upper(v, u)) return v;
    for (int i = lg; i >= 0; --i)
        if (par[u][i] != -1 && !Upper(par[u][i], v))
            u = par[u][i];
    return par[u][0];
}
int Dist(int u, int v)
{
    int p = LCA(u, v);
    int res = 0;
    for (int i = lg; i >= 0; --i)
        if (par[u][i] != -1 && (!Upper(par[u][i], p) || par[u][i] == p))
        {
            res += (1 << i);
            u = par[u][i];
        }
    for (int i = lg; i >= 0; --i)
        if (par[v][i] != -1 && (!Upper(par[v][i], p) || par[v][i] == p))
        {
            res += (1 << i);
            v = par[v][i];
        }
    return res;
}

vector<int> chng;
int lazy[4 * maxN];
void Add(int v, int vl, int vr, int l, int r, int val)
{
    if (r < vl || vr < l)
        return;
    if (l <= vl && vr <= r)
    {
        chng.push_back(v);
        lazy[v] += val;
        return;
    }
    int vm = (vl + vr) / 2;
    Add(v * 2, vl, vm, l, r, val);
    Add(v * 2 + 1, vm + 1, vr, l, r, val);
}
int Get(int v, int vl, int vr, int i)
{
    if (vl == vr)
        return lazy[v];
    int vm = (vl + vr) / 2;
    if (i <= vm)
        return Get(v * 2, vl, vm, i) + lazy[v];
    return Get(v * 2 + 1, vm + 1, vr, i) + lazy[v];
}
int main()
{
    /*ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);*/
    int n, q;
    // cin >> n >> q;
    scanf("%d%d", &n, &q);
    for (int i = 1; i < n; ++i)
    {
        int u, v;
        // cin >> u >> v;
        scanf("%d%d", &u, &v);
        nei[u].push_back(v);
        nei[v].push_back(u);
    }
    DFS(1, -1);
    while (q--)
    {
        int k, m, root;
        // cin >> k >> m >> root;
        scanf("%d%d%d", &k, &m, &root);
        vector<int> a(k);
        for (int& v: a)
        {
            cin >> v;
            is[v] = true;
            Add(1, 1, n, l[v], r[v], 1);
        }
        for (int v: a)
            dist[v] = Dist(root, v);
        sort(a.begin(), a.end(), [](int u, int v) {
             return dist[u] < dist[v];
        });
        for (int v: a)
        {
            int lca = LCA(v, root);
            h[v] = Get(1, 1, n, l[v]) - 1 + Get(1, 1, n, l[root]) - 2 * Get(1, 1, n, l[lca]) + is[lca];
        }
        dp[0][1] = 1;
        for (int i = 1; i < k; ++i)
            for (int j = 1; j <= m; ++j)
                dp[i][j] = (dp[i - 1][j - 1] + (long long)dp[i - 1][j] * (j - h[a[i]])) % mod;
        int ans = 0;
        for (int j = 1; j <= m; ++j)
            ans = (ans + dp[k - 1][j]) % mod;
        // cout << ans << '\n';
        printf("%d\n", ans);
        for (int v: a)
            is[v] = false;
        for (int i = 0; i < k; ++i)
            for (int j = 1; j <= m; ++j)
                dp[i][j] = 0;
        for (int v: chng)
            lazy[v] = 0;
    }
}


#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long llong;
const int maxN = 100'001;
const long long mod = 1000'000'007;

int dp[maxN][301];
int h[maxN];
bool is[maxN];

int l[maxN], r[maxN];
vector<int> nei[maxN];
const int lg = 16;
int par[maxN][lg + 1];
void DFS(int v, int p)
{
    static int time = 0;
    l[v] = ++time;
    par[v][0] = p;
    for (int i = 1; i <= lg; ++i)
        if (par[v][i - 1] != -1)
            par[v][i] = par[par[v][i - 1]][i - 1];
        else
            par[v][i] = -1;
    for (int to: nei[v])
        if (to != p)
            DFS(to, v);
    r[v] = time;
}
inline bool Upper(int u, int v)
{
    return l[u] <= l[v] && r[u] >= r[v];
}
int LCA(int u, int v)
{
    if (Upper(u, v)) return u;
    if (Upper(v, u)) return v;
    for (int i = lg; i >= 0; --i)
        if (par[u][i] != -1 && !Upper(par[u][i], v))
            u = par[u][i];
    return par[u][0];
}
int Dist(int u, int v)
{
    int p = LCA(u, v);
    int res = 0;
    for (int i = lg; i >= 0; --i)
        if (par[u][i] != -1 && (!Upper(par[u][i], p) || par[u][i] == p))
        {
            res += (1 << i);
            u = par[u][i];
        }
    for (int i = lg; i >= 0; --i)
        if (par[v][i] != -1 && (!Upper(par[v][i], p) || par[v][i] == p))
        {
            res += (1 << i);
            v = par[v][i];
        }
    return res;
}

vector<int> chng;
int lazy[4 * maxN];
void Add(int v, int vl, int vr, int l, int r, int val)
{
    if (r < vl || vr < l)
        return;
    if (l <= vl && vr <= r)
    {
        chng.push_back(v);
        lazy[v] += val;
        return;
    }
    int vm = (vl + vr) / 2;
    Add(v * 2, vl, vm, l, r, val);
    Add(v * 2 + 1, vm + 1, vr, l, r, val);
}
int Get(int v, int vl, int vr, int i)
{
    if (vl == vr)
        return lazy[v];
    int vm = (vl + vr) / 2;
    if (i <= vm)
        return Get(v * 2, vl, vm, i) + lazy[v];
    return Get(v * 2 + 1, vm + 1, vr, i) + lazy[v];
}
int main()
{
    /*ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);*/
    int n, q;
    // cin >> n >> q;
    scanf("%d%d", &n, &q);
    for (int i = 1; i < n; ++i)
    {
        int u, v;
        // cin >> u >> v;
        scanf("%d%d", &u, &v);
        nei[u].push_back(v);
        nei[v].push_back(u);
    }
    DFS(1, -1);
    while (q--)
    {
        int k, m, root;
        // cin >> k >> m >> root;
        scanf("%d%d%d", &k, &m, &root);
        vector<int> a(k);
        for (int& v: a)
        {
            cin >> v;
            is[v] = true;
            Add(1, 1, n, l[v], r[v], 1);
        }
        sort(a.begin(), a.end(), [&root](int u, int v) {
             return Dist(root, u) < Dist(root, v);
        });
        for (int v: a)
        {
            int lca = LCA(v, root);
            h[v] = Get(1, 1, n, l[v]) - 1 + Get(1, 1, n, l[root]) - 2 * Get(1, 1, n, l[lca]) + is[lca];
        }
        dp[0][1] = 1;
        for (int i = 1; i < k; ++i)
            for (int j = 1; j <= m; ++j)
                dp[i][j] = (dp[i - 1][j - 1] + (long long)dp[i - 1][j] * (j - h[a[i]])) % mod;
        int ans = 0;
        for (int j = 1; j <= m; ++j)
            ans = (ans + dp[k - 1][j]) % mod;
        // cout << ans << '\n';
        printf("%d\n", ans);
        for (int v: a)
            is[v] = false;
        for (int i = 0; i < k; ++i)
            for (int j = 1; j <= m; ++j)
                dp[i][j] = 0;
        for (int v: chng)
            lazy[v] = 0;
    }
}


#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long llong;
const int maxN = 100'001;
const long long mod = 1000'000'007;

int dp[maxN][301];
int h[maxN];
bool is[maxN];

int l[maxN], r[maxN];
vector<int> nei[maxN];
const int lg = 16;
int par[maxN][lg + 1];
void DFS(int v, int p)
{
    static int time = 0;
    l[v] = ++time;
    par[v][0] = p;
    for (int i = 1; i <= lg; ++i)
        if (par[v][i - 1] != -1)
            par[v][i] = par[par[v][i - 1]][i - 1];
        else
            par[v][i] = -1;
    for (int to: nei[v])
        if (to != p)
            DFS(to, v);
    r[v] = time;
}
inline bool Upper(int u, int v)
{
    return l[u] <= l[v] && r[u] >= r[v];
}
int LCA(int u, int v)
{
    if (Upper(u, v)) return u;
    if (Upper(v, u)) return v;
    for (int i = lg; i >= 0; --i)
        if (par[u][i] != -1 && !Upper(par[u][i], v))
            u = par[u][i];
    return par[u][0];
}
int Dist(int u, int v)
{
    int p = LCA(u, v);
    int res = 0;
    for (int i = lg; i >= 0; --i)
        if (par[u][i] != -1 && (!Upper(par[u][i], p) || par[u][i] == p))
        {
            res += (1 << i);
            u = par[u][i];
        }
    for (int i = lg; i >= 0; --i)
        if (par[v][i] != -1 && (!Upper(par[v][i], p) || par[v][i] == p))
        {
            res += (1 << i);
            v = par[v][i];
        }
    return res;
}

vector<int> chng;
int lazy[4 * maxN];
void Add(int v, int vl, int vr, int l, int r, int val)
{
    if (r < vl || vr < l)
        return;
    if (l <= vl && vr <= r)
    {
        chng.push_back(v);
        lazy[v] += val;
        return;
    }
    int vm = (vl + vr) / 2;
    Add(v * 2, vl, vm, l, r, val);
    Add(v * 2 + 1, vm + 1, vr, l, r, val);
}
int Get(int v, int vl, int vr, int i)
{
    if (vl == vr)
        return lazy[v];
    int vm = (vl + vr) / 2;
    if (i <= vm)
        return Get(v * 2, vl, vm, i) + lazy[v];
    return Get(v * 2 + 1, vm + 1, vr, i) + lazy[v];
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, q;
    cin >> n >> q;
    for (int i = 1; i < n; ++i)
    {
        int u, v;
        cin >> u >> v;
        nei[u].push_back(v);
        nei[v].push_back(u);
    }
    DFS(1, -1);
    while (q--)
    {
        int k, m, root;
        cin >> k >> m >> root;
        vector<int> a(k);
        for (int& v: a)
        {
            cin >> v;
            is[v] = true;
            Add(1, 1, n, l[v], r[v], 1);
        }
        sort(a.begin(), a.end(), [&root](int u, int v) {
             return Dist(root, u) < Dist(root, v);
        });
        for (int v: a)
            h[v] = Get(1, 1, n, l[v]) - 1 + Get(1, 1, n, l[root]) - 2 * Get(1, 1, n, l[LCA(v, root)]) + is[LCA(v, root)];
        dp[0][1] = 1;
        for (int i = 1; i < k; ++i)
            for (int j = 1; j <= m; ++j)
                dp[i][j] = (dp[i - 1][j - 1] + (long long)dp[i - 1][j] * (j - h[a[i]])) % mod;
        int ans = 0;
        for (int j = 1; j <= m; ++j)
            ans = (ans + dp[k - 1][j]) % mod;
        cout << ans << '\n';
        for (int v: a)
            is[v] = false;
        for (int i = 0; i < k; ++i)
            for (int j = 1; j <= m; ++j)
                dp[i][j] = 0;
        for (int v: chng)
            lazy[v] = 0;
    }
}


#include <algorithm>
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
typedef long long llong;
const int maxN = 100'001;
const long long mod = 1000'000'007;
#define assert(X) if (!(bool)(X)) { throw; }

int dp[maxN][301];
int h[maxN];
bool is[maxN];
int dist[maxN];

int l[maxN], r[maxN];
vector<int> nei[maxN];
const int lg = 16;
int par[maxN][lg + 1];
void DFS(int v, int p)
{
    static int time = 0;
    l[v] = ++time;
    par[v][0] = p;
    for (int i = 1; i <= lg; ++i)
        if (par[v][i - 1] != -1)
            par[v][i] = par[par[v][i - 1]][i - 1];
        else
            par[v][i] = -1;
    for (int to: nei[v])
        if (to != p)
            DFS(to, v);
    r[v] = time;
}
inline bool Upper(int u, int v)
{
    return l[u] <= l[v] && r[u] >= r[v];
}
int LCA(int u, int v)
{
    if (Upper(u, v)) return u;
    if (Upper(v, u)) return v;
    for (int i = lg; i >= 0; --i)
        if (par[u][i] != -1 && !Upper(par[u][i], v))
            u = par[u][i];
    return par[u][0];
}
int Dist(int u, int v)
{
    int res = 0;
    for (int i = lg; i >= 0; --i)
        if (par[u][i] != -1 && !Upper(par[u][i], v))
        {
            res += (1 << i);
            u = par[u][i];
        }
    if (!Upper(u, v))
    {
        ++res;
        u = par[u][0];
    }
    for (int i = lg; i >= 0; --i)
        if (par[v][i] != -1 && !Upper(par[v][i], u))
        {
            res += (1 << i);
            v = par[v][i];
        }
    if (!Upper(v, u))
        ++res;
    return res;
}

vector<int> chng;
int lazy[4 * maxN];
void Add(int v, int vl, int vr, int l, int r, int val)
{
    if (r < vl || vr < l)
        return;
    if (l <= vl && vr <= r)
    {
        if (!lazy[v])
            chng.push_back(v);
        lazy[v] += val;
        return;
    }
    int vm = (vl + vr) / 2;
    Add(v * 2, vl, vm, l, r, val);
    Add(v * 2 + 1, vm + 1, vr, l, r, val);
}
int Get(int v, int vl, int vr, int i)
{
    if (vl == vr)
        return lazy[v];
    int vm = (vl + vr) / 2;
    if (i <= vm)
        return Get(v * 2, vl, vm, i) + lazy[v];
    return Get(v * 2 + 1, vm + 1, vr, i) + lazy[v];
}
int main()
{
    /*ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);*/
    int n, q;
    // cin >> n >> q;
    scanf("%d%d", &n, &q);
    for (int i = 1; i < n; ++i)
    {
        int u, v;
        // cin >> u >> v;
        scanf("%d%d", &u, &v);
        nei[u].push_back(v);
        nei[v].push_back(u);
    }
    DFS(1, -1);
    while (q--)
    {
        int k, m, root;
        // cin >> k >> m >> root;
        scanf("%d%d%d", &k, &m, &root);
        vector<int> a(k);
        for (int& v: a)
        {
            // cin >> v;
            scanf("%d", &v);
            is[v] = true;
            Add(1, 1, n, l[v], r[v], 1);
        }
        for (int v: a)
            dist[v] = Dist(root, v);
        sort(a.begin(), a.end(), [](int u, int v) {
             return dist[u] < dist[v];
        });
        for (int v: a)
        {
            int lca = LCA(v, root);
            h[v] = Get(1, 1, n, l[v]) - 1 + Get(1, 1, n, l[root]) - 2 * Get(1, 1, n, l[lca]) + is[lca];
        }
        dp[0][1] = 1;
        for (int i = 1; i < k; ++i)
            for (int j = 1; j <= m; ++j)
                dp[i][j] = (dp[i - 1][j - 1] + (long long)dp[i - 1][j] * (j - h[a[i]])) % mod;
        int ans = 0;
        for (int j = 1; j <= m; ++j)
            ans = (ans + dp[k - 1][j]) % mod;
        // cout << ans << '\n';
        printf("%d\n", ans);
        for (int v: a)
            is[v] = false;
        for (int i = 0; i < k; ++i)
            for (int j = 1; j <= m; ++j)
                dp[i][j] = 0;
        for (int v: chng)
            lazy[v] = 0;
    }
}


#include <algorithm>
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
typedef long long llong;
const int maxN = 100'001;
const long long mod = 1000'000'007;
#define assert(X) if (!(bool)(X)) { throw; }

int dp[maxN][301];
int h[maxN];
bool is[maxN];
int dist[maxN];

int l[maxN], r[maxN];
vector<int> nei[maxN];
const int lg = 16;
int par[maxN][lg + 1];
void DFS(int v, int p)
{
    static int time = 0;
    l[v] = ++time;
    par[v][0] = p;
    for (int i = 1; i <= lg; ++i)
        if (par[v][i - 1] != -1)
            par[v][i] = par[par[v][i - 1]][i - 1];
        else
            par[v][i] = -1;
    for (int to: nei[v])
        if (to != p)
            DFS(to, v);
    r[v] = time;
}
inline bool Upper(int u, int v)
{
    return l[u] <= l[v] && r[u] >= r[v];
}
int LCA(int u, int v)
{
    if (Upper(u, v)) return u;
    if (Upper(v, u)) return v;
    for (int i = lg; i >= 0; --i)
        if (par[u][i] != -1 && !Upper(par[u][i], v))
            u = par[u][i];
    return par[u][0];
}
int Dist(int u, int v)
{
    int res = 0;
    for (int i = lg; i >= 0; --i)
        if (par[u][i] != -1 && !Upper(par[u][i], v))
        {
            res += (1 << i);
            u = par[u][i];
        }
    if (!Upper(u, v))
    {
        ++res;
        u = par[u][0];
    }
    for (int i = lg; i >= 0; --i)
        if (par[v][i] != -1 && !Upper(par[v][i], u))
        {
            res += (1 << i);
            v = par[v][i];
        }
    if (!Upper(v, u))
        ++res;
    return res;
}

vector<int> chng;
int lazy[4 * maxN];
void Add(int v, int vl, int vr, int l, int r, int val)
{
    if (r < vl || vr < l)
        return;
    if (l <= vl && vr <= r)
    {
        if (!lazy[v])
            chng.push_back(v);
        lazy[v] += val;
        return;
    }
    int vm = (vl + vr) / 2;
    Add(v * 2, vl, vm, l, r, val);
    Add(v * 2 + 1, vm + 1, vr, l, r, val);
}
int Get(int v, int vl, int vr, int i)
{
    if (vl == vr)
        return lazy[v];
    int vm = (vl + vr) / 2;
    if (i <= vm)
        return Get(v * 2, vl, vm, i) + lazy[v];
    return Get(v * 2 + 1, vm + 1, vr, i) + lazy[v];
}
int main()
{
    /*ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);*/
    int n, q;
    // cin >> n >> q;
    scanf("%d%d", &n, &q);
    for (int i = 1; i < n; ++i)
    {
        int u, v;
        // cin >> u >> v;
        scanf("%d%d", &u, &v);
        nei[u].push_back(v);
        nei[v].push_back(u);
    }
    DFS(1, -1);
    while (q--)
    {
        int k, m, root;
        // cin >> k >> m >> root;
        scanf("%d%d%d", &k, &m, &root);
        vector<int> a(k);
        for (int& v: a)
        {
            // cin >> v;
            scanf("%d", &v);
            is[v] = true;
            Add(1, 1, n, l[v], r[v], 1);
        }
        for (int v: a)
            dist[v] = Dist(root, v);
        sort(a.begin(), a.end(), [](int u, int v) {
             return dist[u] < dist[v];
        });
        int h_root = Get(1, 1, n, l[root]);
        for (int v: a)
        {
            int lca = LCA(v, root);
            h[v] = Get(1, 1, n, l[v]) - 1 + h_root - 2 * Get(1, 1, n, l[lca]) + is[lca];
        }
        dp[0][1] = 1;
        for (int i = 1; i < k; ++i)
            for (int j = 1; j <= m; ++j)
                dp[i][j] = (dp[i - 1][j - 1] + (long long)dp[i - 1][j] * (j - h[a[i]])) % mod;
        int ans = 0;
        for (int j = 1; j <= m; ++j)
            ans = (ans + dp[k - 1][j]) % mod;
        // cout << ans << '\n';
        printf("%d\n", ans);
        for (int v: a)
            is[v] = false;
        for (int i = 0; i < k; ++i)
            for (int j = 1; j <= m; ++j)
                dp[i][j] = 0;
        for (int v: chng)
            lazy[v] = 0;
    }
}


#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long llong;
const int maxN = 100'001;
const long long mod = 1000'000'007;

int dp[maxN][301];
int h[maxN];
bool is[maxN];

int l[maxN], r[maxN];
vector<int> nei[maxN];
const int lg = 16;
int par[maxN][lg + 1];
void DFS(int v, int p)
{
    static int time = 0;
    l[v] = ++time;
    par[v][0] = p;
    for (int i = 1; i <= lg; ++i)
        if (par[v][i - 1] != -1)
            par[v][i] = par[par[v][i - 1]][i - 1];
        else
            par[v][i] = -1;
    for (int to: nei[v])
        if (to != p)
            DFS(to, v);
    r[v] = time;
}
inline bool Upper(int u, int v)
{
    return l[u] <= l[v] && r[u] >= r[v];
}
int LCA(int u, int v)
{
    if (Upper(u, v)) return u;
    if (Upper(v, u)) return v;
    for (int i = lg; i >= 0; --i)
        if (par[u][i] != -1 && !Upper(par[u][i], v))
            u = par[u][i];
    return par[u][0];
}
int Dist(int u, int v)
{
    int p = LCA(u, v);
    int res = 0;
    for (int i = lg; i >= 0; --i)
        if (par[u][i] != -1 && (!Upper(par[u][i], p) || par[u][i] == p))
        {
            res += (1 << i);
            u = par[u][i];
        }
    for (int i = lg; i >= 0; --i)
        if (par[v][i] != -1 && (!Upper(par[v][i], p) || par[v][i] == p))
        {
            res += (1 << i);
            v = par[v][i];
        }
    return res;
}

vector<int> chng;
int lazy[4 * maxN];
void Add(int v, int vl, int vr, int l, int r, int val)
{
    if (r < vl || vr < l)
        return;
    if (l <= vl && vr <= r)
    {
        chng.push_back(v);
        lazy[v] += val;
        return;
    }
    int vm = (vl + vr) / 2;
    Add(v * 2, vl, vm, l, r, val);
    Add(v * 2 + 1, vm + 1, vr, l, r, val);
}
int Get(int v, int vl, int vr, int i)
{
    if (vl == vr)
        return lazy[v];
    int vm = (vl + vr) / 2;
    if (i <= vm)
        return Get(v * 2, vl, vm, i) + lazy[v];
    return Get(v * 2 + 1, vm + 1, vr, i) + lazy[v];
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, q;
    cin >> n >> q;
    for (int i = 1; i < n; ++i)
    {
        int u, v;
        cin >> u >> v;
        nei[u].push_back(v);
        nei[v].push_back(u);
    }
    DFS(1, -1);
    while (q--)
    {
        int k, m, root;
        cin >> k >> m >> root;
        vector<int> a(k);
        for (int& v: a)
        {
            cin >> v;
            is[v] = true;
            Add(1, 1, n, l[v], r[v], 1);
        }
        sort(a.begin(), a.end(), [&root](int u, int v) {
             return Dist(root, u) < Dist(root, v);
        });
        for (int v: a)
            h[v] = Get(1, 1, n, l[v]) - 1 + Get(1, 1, n, l[root]) - 2 * Get(1, 1, n, l[LCA(v, root)]) + is[LCA(v, root)];
        dp[0][1] = 1;
        for (int i = 1; i < k; ++i)
            for (int j = 1; j <= m; ++j)
                dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j] * (j - h[a[i]])) % mod;
        int ans = 0;
        for (int j = 1; j <= m; ++j)
            ans = (ans + dp[k - 1][j]) % mod;
        cout << ans << '\n';
        for (int v: a)
            is[v] = false;
        for (int i = 0; i < k; ++i)
            for (int j = 1; j <= m; ++j)
                dp[i][j] = 0;
        for (int v: chng)
            lazy[v] = 0;
    }
}


#include <algorithm>
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
typedef long long llong;
const int maxN = 100'001;
const long long mod = 1000'000'007;
#define assert(X) if (!(bool)(X)) { throw; }

int dp[maxN][301];
int h[maxN];
bool is[maxN];
int dist[maxN];

int l[maxN], r[maxN];
vector<int> nei[maxN];
const int lg = 16;
int par[maxN][lg + 1];
void DFS(int v, int p)
{
    static int time = 0;
    l[v] = ++time;
    par[v][0] = p;
    for (int i = 1; i <= lg; ++i)
        if (par[v][i - 1] != -1)
            par[v][i] = par[par[v][i - 1]][i - 1];
        else
            par[v][i] = -1;
    for (int to: nei[v])
        if (to != p)
            DFS(to, v);
    r[v] = time;
}
inline bool Upper(int u, int v)
{
    return l[u] <= l[v] && r[u] >= r[v];
}
int LCA(int u, int v)
{
    if (Upper(u, v)) return u;
    if (Upper(v, u)) return v;
    for (int i = lg; i >= 0; --i)
        if (par[u][i] != -1 && !Upper(par[u][i], v))
            u = par[u][i];
    return par[u][0];
}
int Dist(int u, int v)
{
    int res = 0;
    for (int i = lg; i >= 0; --i)
        if (par[u][i] != -1 && (!Upper(par[u][i], v) || par[u][i] == v))
        {
            res += (1 << i);
            u = par[u][i];
        }
    assert(Upper(u, v));
    for (int i = lg; i >= 0; --i)
        if (par[v][i] != -1 && (!Upper(par[v][i], u) || par[v][i] == u))
        {
            res += (1 << i);
            v = par[v][i];
        }
    return res;
}

vector<int> chng;
int lazy[4 * maxN];
void Add(int v, int vl, int vr, int l, int r, int val)
{
    if (r < vl || vr < l)
        return;
    if (l <= vl && vr <= r)
    {
        chng.push_back(v);
        lazy[v] += val;
        return;
    }
    int vm = (vl + vr) / 2;
    Add(v * 2, vl, vm, l, r, val);
    Add(v * 2 + 1, vm + 1, vr, l, r, val);
}
int Get(int v, int vl, int vr, int i)
{
    if (vl == vr)
        return lazy[v];
    int vm = (vl + vr) / 2;
    if (i <= vm)
        return Get(v * 2, vl, vm, i) + lazy[v];
    return Get(v * 2 + 1, vm + 1, vr, i) + lazy[v];
}
int main()
{
    /*ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);*/
    int n, q;
    // cin >> n >> q;
    scanf("%d%d", &n, &q);
    for (int i = 1; i < n; ++i)
    {
        int u, v;
        // cin >> u >> v;
        scanf("%d%d", &u, &v);
        nei[u].push_back(v);
        nei[v].push_back(u);
    }
    DFS(1, -1);
    while (q--)
    {
        int k, m, root;
        // cin >> k >> m >> root;
        scanf("%d%d%d", &k, &m, &root);
        vector<int> a(k);
        for (int& v: a)
        {
            // cin >> v;
            scanf("%d", &v);
            is[v] = true;
            Add(1, 1, n, l[v], r[v], 1);
        }
        for (int v: a)
            dist[v] = Dist(root, v);
        sort(a.begin(), a.end(), [](int u, int v) {
             return dist[u] < dist[v];
        });
        for (int v: a)
        {
            int lca = LCA(v, root);
            h[v] = Get(1, 1, n, l[v]) - 1 + Get(1, 1, n, l[root]) - 2 * Get(1, 1, n, l[lca]) + is[lca];
        }
        dp[0][1] = 1;
        for (int i = 1; i < k; ++i)
            for (int j = 1; j <= m; ++j)
                dp[i][j] = (dp[i - 1][j - 1] + (long long)dp[i - 1][j] * (j - h[a[i]])) % mod;
        int ans = 0;
        for (int j = 1; j <= m; ++j)
            ans = (ans + dp[k - 1][j]) % mod;
        // cout << ans << '\n';
        printf("%d\n", ans);
        for (int v: a)
            is[v] = false;
        for (int i = 0; i < k; ++i)
            for (int j = 1; j <= m; ++j)
                dp[i][j] = 0;
        for (int v: chng)
            lazy[v] = 0;
    }
}