#include <string.h>
#include <unordered_map>

#include <sstream>
#include <stdio.h>
#include <assert.h>
#include <math.h>
#include <bitset>
#include <algorithm>
#include <iostream>
#include   <stdlib.h>
#include   <time.h>
#include <stack>
#include <queue>
#include <set>

#include <map>
#include <vector>
#include <string>
#include <stdlib.h>

#define ll long long
#define clr(x) memset(x,0,sizeof(x))
#define _clr(x) memset(x,-1,sizeof(x))
#define fr(i,a,b) for(int i = a; i < b; ++i)
#define frr(i,a,b) for(int i = a; i > b; --i)
#define pb push_back
#define sf scanf

#define pf printf
#define mp make_pair

using namespace std;
ll mod = 1000000007;
int n,q;

struct Edge{
	int a,b,next;
	Edge(){}
	Edge(int a, int b, int next):a(a),b(b),next(next){}
}e[1000010];

int p[100010];
int tot;

void add(int a, int b) {
	e[tot] = Edge(a,b,p[a]);
	p[a]=tot++;
}

vector<int> g[1000010];
int in[1000010],out[1000010],path[1000010],id;
int f[100010],rmq[1000010][21];
int fa[1000010],dep[1000010];
int a[1000010];
ll dp[2][301];

void dfs(int t, int f) {
	fa[t] = f;
	path[id]=t;
	in[t] = id++;
	dep[t] = dep[f]+1;

	for(int i : g[t]) {
		if(i==f)continue;
		dfs(i,t);
		path[id++] = t;
	}
}

void init() {
	for(int i = 0; i <id; ++i) {
		rmq[i][0] = path[i];
		//printf("i = %d path = %d\n",i,path[i]);
	}

	for(int j = 1; j <=20; ++j) {
		for(int i = 0; i < id; ++i) {
			rmq[i][j] = dep[rmq[i][j-1]]<dep[rmq[i+(1<<(j-1))][j-1]]?rmq[i][j-1]:rmq[i+(1<<(j-1))][j-1];
		}
	}
}

int lca(int a, int b) {
	if(in[a]>in[b]) swap(a,b);
	int s = in[a], e = in[b];
	int k = 0;
	for(; (1<<k)<=(e-s+1);++k);
	k--;
	//printf("a = %d b = %d s = %d e = %d k = %d\n",a,b,s,e,k);
	return dep[rmq[s][k]]<dep[rmq[e-(1<<k)+1][k]]?rmq[s][k]:rmq[e-(1<<k)+1][k];
}

int k,m,r;
int v[100010];
int num;
vector<int> nima;

void dfs1(int t, int fa) {
	//printf("dfs1 t = %d fa = %d num = %d %d\n",t,fa,num,v[t]);
	f[t] = num;
	if(v[t]){
		nima.pb(t);
		++num;
	}
	for(int i = p[t]; i !=-1; i = e[i].next) {
		if(e[i].b==fa)continue;
		dfs1(e[i].b,t);
	}

	if(v[t])--num;
}

int sol() {

	clr(v);
	auto cmp = [&](const int i, int j) {
		return in[i]<in[j];
	};

	int root = a[0];
	for(int i = 0; i < k; ++i) {
		v[a[i]]=1;
		root = lca(root, a[i]);
		//printf("root = %d ai = %d\n",root,a[i]);
	}
	//printf("root = %d\n",root);
	if(v[r]==0) {
		a[k++]=r;
	}
	if(!v[root])a[k++]=root;

	sort(a,a+k,cmp);

	stack<int> st;
	_clr(p);
	tot = 0;
	for(int i = 0; i < k;++i) {
		//printf("ft i = %d ft = %d\n",i,a[i]);
		if(st.empty()) {
			st.push(a[i]);
		}
		else {
			if(lca(a[i],st.top())==st.top()) {
				//printf("push 1 %d\n",a[i]);
				st.push(a[i]);
			}
			else {
				while(dep[st.top()]>dep[lca(a[i],st.top())]) {
					int t = st.top();
					st.pop();
					//printf("add t = %d %d\n",t,st.top());
					add(t,st.top());
					add(st.top(),t);
				}
				//printf("top = %d ai = %d\n",st.top(), a[i]);
				int lca_t = lca(a[i], st.top());
				if(lca_t != st.top()) {
					//printf("add lca_t = %d %d\n",lca_t,st.top());
					add(lca_t,st.top());
					add(st.top(),lca_t);
					st.pop();
					//printf("push lca %d\n",lca_t);
					st.push(lca_t);
				}
				//printf("push %d\n",a[i]);
				st.push(a[i]);
			}
		}
	}
	while(!st.empty()&&st.size()>1) {
		int t = st.top();
		st.pop();
		//printf("add left t = %d %d\n",t,st.top());
		add(t,st.top());
		add(st.top(),t);
	}
	num = 0;
	nima.clear();
	dfs1(r,r);

	clr(dp);
	dp[1][1] = 1;
	//printf("i = 0 a = %d\n",nima[0]);
	for(int i = 2; i <= nima.size(); ++i) {
		int index = i&1;
		int pre = index ^1;
		clr(dp[index]);
		for(int j = 1; j <=m; ++j) {
			dp[index][j] = (dp[pre][j-1] + dp[pre][j]*(j-f[nima[i-1]]))%mod;
			//printf("i = %d j = %d a = %d dp = %lld f = %d\n",i,j,nima[i-1],dp[index][j], f[nima[i-1]]);
		}
	}
	ll ans = 0;
	for(int i = 1; i<=m;++i) {
		ans = (ans + dp[(nima.size())&1][i])%mod;
	}
	return ans;
}

int main(){
	while(cin>>n>>q){
		fr(i,0,n-1) {
			int u,v;
			sf("%d%d",&u,&v);
			g[u].pb(v);
			g[v].pb(u);
		}
		id = 0;
		dfs(1,1);
		/*
		for(int i = 0; i < id; ++i) {
			printf("%d ",path[i]);
		}
		for(int i = 1;i <=n; ++i) {
			printf("i = %d in = %d out = %d\n",i,in[i],out[i]);
		}
		*/
		init();
		fr(i,0,q) {
			sf("%d%d%d",&k,&m,&r);
			for(int j = 0; j < k; ++j) {
				sf("%d",&a[j]);
			}
			cout<<sol()<<endl;
		}
	}
}


#include <string.h>
#include <unordered_map>

#include <sstream>
#include <stdio.h>
#include <assert.h>
#include <math.h>
#include <bitset>
#include <algorithm>
#include <iostream>
#include   <stdlib.h>
#include   <time.h>
#include <stack>
#include <queue>
#include <set>

#include <map>
#include <vector>
#include <string>
#include <stdlib.h>

#define ll long long
#define clr(x) memset(x,0,sizeof(x))
#define _clr(x) memset(x,-1,sizeof(x))
#define fr(i,a,b) for(int i = a; i < b; ++i)
#define frr(i,a,b) for(int i = a; i > b; --i)
#define pb push_back
#define sf scanf

#define pf printf
#define mp make_pair

using namespace std;
ll mod = 1000000007;
int n,q;

struct Edge{
	int a,b,next;
	Edge(){}
	Edge(int a, int b, int next):a(a),b(b),next(next){}
}e[1000010];

int p[1000010];
int tot;

void add(int a, int b) {
	e[tot] = Edge(a,b,p[a]);
	p[a]=tot++;
}

vector<int> g[1000010];
int in[1000010],out[1000010],path[1000010],id;
int f[100010],la[1000010][21];
int fa[1000010],dep[1000010];
int a[1000010];
ll dp[2][301];

void dfs(int t, int f) {
	fa[t] = f;
	path[id]=t;
	in[t] = id++;
	dep[t] = dep[f]+1;

	for(int i : g[t]) {
		if(i==f)continue;
		dfs(i,t);
	}

	path[id] = t;
	out[t] = id++;
}

void init() {
	for(int i = 1; i <=n; ++i) {
		la[i][0] = fa[i];
		//printf("i = %d fa = %d\n",i,fa[i]);
	}

	for(int j = 1; j <=20; ++j) {
		for(int i = 1; i <=n; ++i) {
			la[i][j] = la[ la[i][j-1] ][j-1];
			//printf("i = %d j = %d laj-1 = %d la = %d\n",i,j,la[i][j-1],la[i][j]);
		}
	}
}

int lca(int a, int b) {

	if(dep[a]<dep[b])swap(a,b);
	//printf("lca a = %d b = %d, depa = %d depb = %d\n",a,b,dep[a],dep[b]);
	for(int i = 20; i >=0;--i) {
		if(dep[la[a][i]]>=dep[b]) {
			//printf("a = %d i = %d la = %d\n",a,i,la[a][i]);
			a = la[a][i];
		}
	}
	if(a==b)return a;
	//printf("a = %d b = %d\n",a,b);
	for(int i = 20; i >=0; --i) {
		//printf("i = %d a = %d b = %d f = %d %d\n",i,a,b,la[a][i],la[b][i]);
		if(la[a][i]!=la[b][i]) {
			//printf("i = %d a = %d b = %d f = %d %d\n",i,a,b,la[a][i],la[b][i]);
			a = la[a][i];
			b = la[b][i];
		}
	}
	//printf("a = %d b = %d\n",a,b);
	return la[a][0];
}

int k,m,r;
int v[1000010];
int num;
stack<int> stt;
vector<int> nima;

void dfs1(int t, int fa) {
	//printf("dfs1 t = %d fa = %d num = %d %d\n",t,fa,num,v[t]);
	f[t] = num;
	if(v[t]){
		nima.pb(t);
		++num;
	}
	stt.push(t);
	for(int i = p[t]; i !=-1; i = e[i].next) {
		if(e[i].b==fa)continue;
		dfs1(e[i].b,t);
	}

	if(v[t])--num;
	stt.pop();
}
int sol() {

	clr(v);
	auto cmp = [&](const int i, int j) {
		return in[i]<in[j];
	};

	for(int i = 0; i < k; ++i) {
		v[a[i]]=1;
	}
	if(v[r]==0) {
		a[k++]=r;
	}

	sort(a,a+k,cmp);

	int flag = 0;
	set<int> sb;
	vector<int> ft;
	for(int i = 0; i < k; ++i) {
		if(i==0) {
			ft.pb(a[i]);
			sb.insert(a[i]);
		}
		else {
			int lca_i = lca(a[i],a[i-1]);
			//printf("lca i = %d i-1 = %d lca = %d\n",a[i],a[i-1],lca_i);
			if(sb.find(lca_i)==sb.end()) {
				sb.insert(lca_i);
				ft.pb(lca_i);
			}
			sb.insert(a[i]);
			ft.pb(a[i]);
		}
	}

	sort(ft.begin(), ft.end(),cmp);
	stack<int> st;

	_clr(p);
	tot = 0;
	for(int i = 0; i < ft.size();++i) {
		//printf("ft i = %d ft = %d\n",i,ft[i]);
		while(!st.empty()&&lca(ft[i],st.top())!=st.top()) st.pop();
		if(st.size()){
			//printf("add %d %d\n",ft[i],st.top());
			add(ft[i],st.top());
			add(st.top(),ft[i]);
		}
		st.push(ft[i]);
	}
	num = 0;
	nima.clear();
	dfs1(r,r);

	dp[1][1] = 1;
	//printf("i = 0 a = %d\n",nima[0]);
	for(int i = 2; i <= nima.size(); ++i) {
		int index = i&1;
		int pre = index ^1;
		clr(dp[index]);
		for(int j = 1; j <=m; ++j) {
			dp[index][j] = (dp[pre][j-1] + dp[pre][j]*(j-f[nima[i-1]]))%mod;
			//printf("i = %d j = %d a = %d dp = %lld f = %d\n",i,j,nima[i-1],dp[index][j], f[nima[i-1]]);
		}
	}
	ll ans = 0;
	for(int i = 1; i<=m;++i) {
		ans = (ans + dp[(nima.size())&1][i])%mod;
	}
	return ans;
}

int main(){
	while(cin>>n>>q){
		fr(i,0,n-1) {
			int u,v;
			sf("%d%d",&u,&v);
			g[u].pb(v);
			g[v].pb(u);
		}
		id = 0;
		dfs(1,1);
		/*
		for(int i = 0; i < id; ++i) {
			printf("%d ",path[i]);
		}
		for(int i = 1;i <=n; ++i) {
			printf("i = %d in = %d out = %d\n",i,in[i],out[i]);
		}
		*/
		init();
		fr(i,0,q) {
			sf("%d%d%d",&k,&m,&r);
			for(int j = 0; j < k; ++j) {
				sf("%d",&a[j]);
			}
			cout<<sol()<<endl;
		}
	}
}


#include <string.h>
#include <unordered_map>

#include <sstream>
#include <stdio.h>
#include <assert.h>
#include <math.h>
#include <bitset>
#include <algorithm>
#include <iostream>
#include   <stdlib.h>
#include   <time.h>
#include <stack>
#include <queue>
#include <set>

#include <map>
#include <vector>
#include <string>
#include <stdlib.h>

#define ll long long
#define clr(x) memset(x,0,sizeof(x))
#define _clr(x) memset(x,-1,sizeof(x))
#define fr(i,a,b) for(int i = a; i < b; ++i)
#define frr(i,a,b) for(int i = a; i > b; --i)
#define pb push_back
#define sf scanf

#define pf printf
#define mp make_pair

using namespace std;
ll mod = 1000000007;
int n,q;

vector<int> g[1000010];
int in[1000010],out[1000010],path[1000010],id;
int f[100010],la[1000010][21];
int fa[1000010],dep[1000010];
int a[1000010];
ll dp[2][301];

void dfs(int t, int f) {
	fa[t] = f;
	path[id]=t;
	in[t] = id++;
	dep[t] = dep[f]+1;

	for(int i : g[t]) {
		if(i==f)continue;
		dfs(i,t);
	}

	path[id] = t;
	out[t] = id++;
}

void init() {
	for(int i = 1; i <=n; ++i) {
		la[i][0] = fa[i];
		//printf("i = %d fa = %d\n",i,fa[i]);
	}

	for(int j = 1; j <=20; ++j) {
		for(int i = 1; i <=n; ++i) {
			la[i][j] = la[ la[i][j-1] ][j-1];
			//printf("i = %d j = %d laj-1 = %d la = %d\n",i,j,la[i][j-1],la[i][j]);
		}
	}
}

int lca(int a, int b) {

	if(dep[a]<dep[b])swap(a,b);
	//printf("lca a = %d b = %d, depa = %d depb = %d\n",a,b,dep[a],dep[b]);
	for(int i = 20; i >=0;--i) {
		if(dep[la[a][i]]>=dep[b]) {
			//printf("a = %d i = %d la = %d\n",a,i,la[a][i]);
			a = la[a][i];
		}
	}
	//printf("a = %d b = %d\n",a,b);
	for(int i = 20; i >=0; --i) {
		//printf("i = %d a = %d b = %d f = %d %d\n",i,a,b,la[a][i],la[b][i]);
		if(la[a][i]!=la[b][i]) {
			//printf("i = %d a = %d b = %d f = %d %d\n",i,a,b,la[a][i],la[b][i]);
			a = la[a][i];
			b = la[b][i];
		}
	}
	//printf("a = %d b = %d\n",a,b);
	return la[a][0];
}

int k,m,r;

int sol() {

	auto cmp = [&](const int i, int j) {
		int lca_i = lca(i,r);
		int lca_j = lca(j,r);
		//printf("sort r = %d i = %d lca_I = %d j = %d lca_j = %d\n",r,i,lca_i,j,lca_j);
		if(lca_i==r&&lca_j==r) {
			return in[i]<in[j];
		}
		else if(lca_i==r&&lca_j!=r) {
			return false;
		}else if(lca_i!=r&&lca_j==r) {
			return true;
		}
		else {
			if(lca_i==lca_j) {
				return in[i]<in[j];
			}
			else if(lca_i==i||lca_j==j) {
				return dep[lca_i]>dep[lca_j];
			}
			else {
				return in[i]<in[j];
			}
		}
	};

	sort(a,a+k,cmp);

	stack<int> st;
	for(int i = 0; i < k; ++i) {
		int lca_i = lca(a[i],r);
		//printf("i = %d a = %d r = %d lca = %d\n",i,a[i],r,lca_i);
		while(!st.empty()) {
			int t = st.top();
			int lca_t = lca(t,r);
			//printf("st t = %d r = %d lca = %d\n",t,r,lca_t);
			if(lca_t == r && lca_i == r) {
				if(out[a[i]]>out[t]) {
					st.pop();
					continue;
				}
			}
			else if(lca_t==r &&lca_i!=r) {
				break;
			}
			else if(lca_t!=r && lca_i==r) {
				st.pop();
				continue;
			}
			else {
				if(lca_i==lca_t) {
					if(out[a[i]]>out[t]) {
						st.pop();
						continue;
					}
				}
				else if(lca_i == a[i] || lca_t == t) {
					if(dep[lca_t]<dep[lca_i]) {
						st.pop();
						continue;
					}
					else {
						if(lca_t !=t) {
							st.pop();
							continue;
						}
					}
				}
				else {
					if(out[a[i]]>out[t]) {
						st.pop();
						continue;
					}
				}
			}
			break;
		}
		f[i] = st.size();
		//printf("i = %d f i = %d\n",i,f[i]);
		st.push(a[i]);
	}

	dp[1][1] = 1;
	for(int i = 2; i <= k; ++i) {
		int index = i&1;
		int pre = index ^1;
		clr(dp[index]);
		for(int j = 1; j <=m; ++j) {
			dp[index][j] = (dp[pre][j-1] + dp[pre][j]*(j-f[i-1]))%mod;
			//printf("i = %d j = %d dp = %d f = %d\n",i,j,dp[index][j], f[i-1]);
		}
	}
	ll ans = 0;
	for(int i = 1; i<=m;++i) {
		ans = (ans + dp[k&1][i])%mod;
	}
	return ans;
}

int main(){
	while(cin>>n>>q){
		fr(i,0,n-1) {
			int u,v;
			sf("%d%d",&u,&v);
			g[u].pb(v);
			g[v].pb(u);
		}
		id = 0;
		dfs(1,1);
		/*
		for(int i = 0; i < id; ++i) {
			printf("%d ",path[i]);
		}
		for(int i = 1;i <=n; ++i) {
			printf("i = %d in = %d out = %d\n",i,in[i],out[i]);
		}
		*/
		init();
		fr(i,0,q) {
			sf("%d%d%d",&k,&m,&r);
			for(int j = 0; j < k; ++j) {
				sf("%d",&a[j]);
			}
			cout<<sol()<<endl;
		}
	}
}


#include <string.h>
#include <unordered_map>

#include <sstream>
#include <stdio.h>
#include <assert.h>
#include <math.h>
#include <bitset>
#include <algorithm>
#include <iostream>
#include   <stdlib.h>
#include   <time.h>
#include <stack>
#include <queue>
#include <set>

#include <map>
#include <vector>
#include <string>
#include <stdlib.h>

#define ll long long
#define clr(x) memset(x,0,sizeof(x))
#define _clr(x) memset(x,-1,sizeof(x))
#define fr(i,a,b) for(int i = a; i < b; ++i)
#define frr(i,a,b) for(int i = a; i > b; --i)
#define pb push_back
#define sf scanf

#define pf printf
#define mp make_pair

using namespace std;
ll mod = 1000000007;
int n,q;

struct Edge{
	int a,b,next;
	Edge(){}
	Edge(int a, int b, int next):a(a),b(b),next(next){}
}e[1000010];

int p[100010];
int tot;

void add(int a, int b) {
	e[tot] = Edge(a,b,p[a]);
	p[a]=tot++;
}

vector<int> g[1000010];
int in[1000010],out[1000010],path[1000010],id;
int f[100010],rmq[1000010][21];
int fa[1000010],dep[1000010];
int a[1000010];
ll dp[2][301];

void dfs(int t, int f) {
	fa[t] = f;
	path[id]=t;
	in[t] = id++;
	dep[t] = dep[f]+1;

	for(int i : g[t]) {
		if(i==f)continue;
		dfs(i,t);
		path[id++] = t;
	}
}

void init() {
	for(int i = 0; i <id; ++i) {
		rmq[i][0] = path[i];
		//printf("i = %d path = %d\n",i,path[i]);
	}

	for(int j = 1; j <=20; ++j) {
		for(int i = 0; i < id; ++i) {
			rmq[i][j] = dep[rmq[i][j-1]]<dep[rmq[i+(1<<(j-1))][j-1]]?rmq[i][j-1]:rmq[i+(1<<(j-1))][j-1];
		}
	}
}

int lca(int a, int b) {
	if(in[a]>in[b]) swap(a,b);
	int s = in[a], e = in[b];
	int k = 0;
	for(; (1<<k)<=(e-s+1);++k);
	k--;
	//printf("a = %d b = %d s = %d e = %d k = %d\n",a,b,s,e,k);
	return dep[rmq[s][k]]<dep[rmq[e-(1<<k)+1][k]]?rmq[s][k]:rmq[e-(1<<k)+1][k];
}

int k,m,r;
int v[100010];
int num;
vector<int> nima;

void dfs1(int t, int fa) {
	//printf("dfs1 t = %d fa = %d num = %d %d\n",t,fa,num,v[t]);
	f[t] = num;
	if(v[t]){
		nima.pb(t);
		++num;
	}
	for(int i = p[t]; i !=-1; i = e[i].next) {
		if(e[i].b==fa)continue;
		dfs1(e[i].b,t);
	}

	if(v[t])--num;
}
int sol() {

	clr(v);
	auto cmp = [&](const int i, int j) {
		return in[i]<in[j];
	};

	for(int i = 0; i < k; ++i) {
		v[a[i]]=1;
	}
	if(v[r]==0) {
		a[k++]=r;
	}

	sort(a,a+k,cmp);

	int flag = 0;
	set<int> sb;
	vector<int> ft;
	for(int i = 0; i < k; ++i) {
		if(i==0) {
			ft.pb(a[i]);
			sb.insert(a[i]);
		}
		else {
			int lca_i = lca(a[i],a[i-1]);
			//printf("lca i = %d i-1 = %d lca = %d\n",a[i],a[i-1],lca_i);
			if(sb.find(lca_i)==sb.end()) {
				sb.insert(lca_i);
				ft.pb(lca_i);
			}
			sb.insert(a[i]);
			ft.pb(a[i]);
		}
	}

	sort(ft.begin(), ft.end(),cmp);
	stack<int> st;

	_clr(p);
	tot = 0;
	for(int i = 0; i < ft.size();++i) {
		//printf("ft i = %d ft = %d\n",i,ft[i]);
		while(!st.empty()&&lca(ft[i],st.top())!=st.top()) st.pop();
		if(st.size()){
			//printf("add %d %d\n",ft[i],st.top());
			add(ft[i],st.top());
			add(st.top(),ft[i]);
		}
		st.push(ft[i]);
	}
	num = 0;
	nima.clear();
	dfs1(r,r);

	clr(dp);
	dp[1][1] = 1;
	//printf("i = 0 a = %d\n",nima[0]);
	for(int i = 2; i <= nima.size(); ++i) {
		int index = i&1;
		int pre = index ^1;
		clr(dp[index]);
		for(int j = 1; j <=m; ++j) {
			dp[index][j] = (dp[pre][j-1] + dp[pre][j]*(j-f[nima[i-1]]))%mod;
			//printf("i = %d j = %d a = %d dp = %lld f = %d\n",i,j,nima[i-1],dp[index][j], f[nima[i-1]]);
		}
	}
	ll ans = 0;
	for(int i = 1; i<=m;++i) {
		ans = (ans + dp[(nima.size())&1][i])%mod;
	}
	return ans;
}

int main(){
	while(cin>>n>>q){
		fr(i,0,n-1) {
			int u,v;
			sf("%d%d",&u,&v);
			g[u].pb(v);
			g[v].pb(u);
		}
		id = 0;
		dfs(1,1);
		/*
		for(int i = 0; i < id; ++i) {
			printf("%d ",path[i]);
		}
		for(int i = 1;i <=n; ++i) {
			printf("i = %d in = %d out = %d\n",i,in[i],out[i]);
		}
		*/
		init();
		fr(i,0,q) {
			sf("%d%d%d",&k,&m,&r);
			for(int j = 0; j < k; ++j) {
				sf("%d",&a[j]);
			}
			cout<<sol()<<endl;
		}
	}
}


#include <string.h>
#include <unordered_map>

#include <sstream>
#include <stdio.h>
#include <assert.h>
#include <math.h>
#include <bitset>
#include <algorithm>
#include <iostream>
#include   <stdlib.h>
#include   <time.h>
#include <stack>
#include <queue>
#include <set>

#include <map>
#include <vector>
#include <string>
#include <stdlib.h>

#define ll long long
#define clr(x) memset(x,0,sizeof(x))
#define _clr(x) memset(x,-1,sizeof(x))
#define fr(i,a,b) for(int i = a; i < b; ++i)
#define frr(i,a,b) for(int i = a; i > b; --i)
#define pb push_back
#define sf scanf

#define pf printf
#define mp make_pair

using namespace std;
ll mod = 1000000007;
int n,q;

struct Edge{
	int a,b,next;
	Edge(){}
	Edge(int a, int b, int next):a(a),b(b),next(next){}
}e[1000010];

int p[100010];
int tot;

void add(int a, int b) {
	e[tot] = Edge(a,b,p[a]);
	p[a]=tot++;
}

vector<int> g[1000010];
int in[1000010],out[1000010],path[1000010],id;
int f[100010],rmq[1000010][21];
int fa[1000010],dep[1000010];
int a[1000010];
ll dp[2][301];

void dfs(int t, int f) {
	fa[t] = f;
	path[id]=t;
	in[t] = id++;
	dep[t] = dep[f]+1;

	for(int i : g[t]) {
		if(i==f)continue;
		dfs(i,t);
		path[id++] = t;
	}
}

void init() {
	for(int i = 0; i <id; ++i) {
		rmq[i][0] = path[i];
		//printf("i = %d path = %d\n",i,path[i]);
	}

	for(int j = 1; j <=20; ++j) {
		for(int i = 0; i < id; ++i) {
			rmq[i][j] = dep[rmq[i][j-1]]<dep[rmq[i+(1<<(j-1))][j-1]]?rmq[i][j-1]:rmq[i+(1<<(j-1))][j-1];
		}
	}
}

int lca(int a, int b) {
	if(in[a]>in[b]) swap(a,b);
	int s = in[a], e = in[b];
	int k = 0;
	for(; (1<<k)<=(e-s+1);++k);
	k--;
	//printf("a = %d b = %d s = %d e = %d k = %d\n",a,b,s,e,k);
	return dep[rmq[s][k]]<dep[rmq[e-(1<<k)+1][k]]?rmq[s][k]:rmq[e-(1<<k)+1][k];
}

int k,m,r;
int v[100010];
int num;
vector<int> nima;
int st[1000010];

void dfs1(int t, int fa) {
	//printf("dfs1 t = %d fa = %d num = %d %d\n",t,fa,num,v[t]);
	f[t] = num;
	if(v[t]){
		nima.pb(t);
		++num;
	}
	for(int i = p[t]; i !=-1; i = e[i].next) {
		if(e[i].b==fa)continue;
		dfs1(e[i].b,t);
	}

	if(v[t])--num;
}

int sol() {

	clr(v);
	auto cmp = [&](const int i, int j) {
		return in[i]<in[j];
	};

	int root = a[0];
	for(int i = 0; i < k; ++i) {
		v[a[i]]=1;
		root = lca(root, a[i]);
		//printf("root = %d ai = %d\n",root,a[i]);
	}
	//printf("root = %d\n",root);
	if(v[r]==0) {
		a[k++]=r;
	}
	if(!v[root])a[k++]=root;

	sort(a,a+k,cmp);

	int top = 0;
	_clr(p);
	tot = 0;
	for(int i = 0; i < k;++i) {
		//printf("ft i = %d ft = %d\n",i,a[i]);
		if(top==0) {
			st[top++]=a[i];
		}
		else {
			if(lca(a[i],a[i-1])==a[i-1]) {
				//printf("push 1 %d\n",a[i]);
				st[top++]=a[i];
			}
			else {
				int lca_t = lca(a[i], a[i-1]);
				while(top>1&&dep[st[top-2]]>dep[lca_t]) {
					//printf("add t = %d %d\n",st[top-1],st[top-2]);
					add(st[top-1],st[top-2]);
					add(st[top-2],st[top-1]);
					top--;
				}
				if(top>0&&dep[st[top-1]] > dep[lca_t]) {
					//printf("add lcat = %d %d\n",st[top-1],lca_t);
					add(st[top-1],lca_t);
					add(lca_t,st[top-1]);
					top--;
				}

				if(top==0||st[top-1] != lca_t) {
					//printf("push %d\n",lca_t);
					st[top++]=lca_t;
				}

				//printf("push %d\n",a[i]);
				st[top++]=a[i];
			}
		}
	}
	while(top>1) {
		//printf("add left = %d %d\n",st[top-1],st[top-2]);
		add(st[top-1],st[top-2]);
		add(st[top-2],st[top-1]);
		top--;
	}
	num = 0;
	nima.clear();
	dfs1(r,r);

	clr(dp);
	dp[1][1] = 1;
	//printf("i = 0 a = %d\n",nima[0]);
	for(int i = 2; i <= nima.size(); ++i) {
		int index = i&1;
		int pre = index ^1;
		clr(dp[index]);
		for(int j = 1; j <=m; ++j) {
			dp[index][j] = (dp[pre][j-1] + dp[pre][j]*(j-f[nima[i-1]]))%mod;
			//printf("i = %d j = %d a = %d dp = %lld f = %d\n",i,j,nima[i-1],dp[index][j], f[nima[i-1]]);
		}
	}
	ll ans = 0;
	for(int i = 1; i<=m;++i) {
		ans = (ans + dp[(nima.size())&1][i])%mod;
	}
	return ans;
}

int main(){
	while(cin>>n>>q){
		fr(i,0,n-1) {
			int u,v;
			sf("%d%d",&u,&v);
			g[u].pb(v);
			g[v].pb(u);
		}
		id = 0;
		dfs(1,1);
		/*
		for(int i = 0; i < id; ++i) {
			printf("%d ",path[i]);
		}
		for(int i = 1;i <=n; ++i) {
			printf("i = %d in = %d out = %d\n",i,in[i],out[i]);
		}
		*/
		init();
		fr(i,0,q) {
			sf("%d%d%d",&k,&m,&r);
			for(int j = 0; j < k; ++j) {
				sf("%d",&a[j]);
			}
			cout<<sol()<<endl;
		}
	}
}


#include <string.h>
#include <unordered_map>

#include <sstream>
#include <stdio.h>
#include <assert.h>
#include <math.h>
#include <bitset>
#include <algorithm>
#include <iostream>
#include   <stdlib.h>
#include   <time.h>
#include <stack>
#include <queue>
#include <set>

#include <map>
#include <vector>
#include <string>
#include <stdlib.h>

#define ll long long
#define clr(x) memset(x,0,sizeof(x))
#define _clr(x) memset(x,-1,sizeof(x))
#define fr(i,a,b) for(int i = a; i < b; ++i)
#define frr(i,a,b) for(int i = a; i > b; --i)
#define pb push_back
#define sf scanf

#define pf printf
#define mp make_pair

using namespace std;
ll mod = 1000000007;
int n,q;

vector<int> g[1000010];
int in[1000010],out[1000010],path[1000010],id;
int f[100010],la[1000010][21];
int fa[1000010],dep[1000010];
int a[1000010];
int dp[100010][301];

void dfs(int t, int f) {
	fa[t] = f;
	path[id]=t;
	in[t] = id++;
	dep[t] = dep[f]+1;

	for(int i : g[t]) {
		if(i==f)continue;
		dfs(i,t);
	}

	path[id] = t;
	out[t] = id++;
}

void init() {
	for(int i = 1; i <=n; ++i) {
		la[i][0] = fa[i];
		//printf("i = %d fa = %d\n",i,fa[i]);
	}

	for(int j = 1; j <=20; ++j) {
		for(int i = 1; i <=n; ++i) {
			la[i][j] = la[ la[i][j-1] ][j-1];
			//printf("i = %d j = %d laj-1 = %d la = %d\n",i,j,la[i][j-1],la[i][j]);
		}
	}
}

int lca(int a, int b) {

	if(dep[a]<dep[b])swap(a,b);
	//printf("lca a = %d b = %d, depa = %d depb = %d\n",a,b,dep[a],dep[b]);
	for(int i = 20; i >=0;--i) {
		if(dep[la[a][i]]>=dep[b]) {
			//printf("a = %d i = %d la = %d\n",a,i,la[a][i]);
			a = la[a][i];
		}
	}
	//printf("a = %d b = %d\n",a,b);
	for(int i = 20; i >=0; --i) {
		//printf("i = %d a = %d b = %d f = %d %d\n",i,a,b,la[a][i],la[b][i]);
		if(la[a][i]!=la[b][i]) {
			//printf("i = %d a = %d b = %d f = %d %d\n",i,a,b,la[a][i],la[b][i]);
			a = la[a][i];
			b = la[b][i];
		}
	}
	//printf("a = %d b = %d\n",a,b);
	return la[a][0];
}

int k,m,r;

int sol() {

	auto cmp = [&](const int i, int j) {
		int lca_i = lca(i,r);
		int lca_j = lca(j,r);
		//printf("sort r = %d i = %d lca_I = %d j = %d lca_j = %d\n",r,i,lca_i,j,lca_j);
		if(lca_i==r&&lca_j==r) {
			return in[i]<in[j];
		}
		else if(lca_i==r&&lca_j!=r) {
			return false;
		}else if(lca_i!=r&&lca_j==r) {
			return true;
		}
		else {
			if(lca_i==lca_j) {
				return in[i]<in[j];
			}
			else if(lca_i==i||lca_j==j) {
				return dep[lca_i]>dep[lca_j];
			}
			else {
				return in[i]<in[j];
			}
		}
	};

	sort(a,a+k,cmp);

	stack<int> st;
	for(int i = 0; i < k; ++i) {
		int lca_i = lca(a[i],r);
		//printf("i = %d a = %d r = %d lca = %d\n",i,a[i],r,lca_i);
		while(!st.empty()) {
			int t = st.top();
			int lca_t = lca(t,r);
			//printf("st t = %d r = %d lca = %d\n",t,r,lca_t);
			if(lca_t == r && lca_i == r) {
				if(out[a[i]]>out[t]) {
					st.pop();
					continue;
				}
			}
			else if(lca_t==r &&lca_i!=r) {
				break;
			}
			else if(lca_t!=r && lca_i==r) {
				st.pop();
				continue;
			}
			else {
				if(lca_i==lca_t) {
					if(out[a[i]]>out[t]) {
						st.pop();
						continue;
					}
				}
				else if(lca_i == a[i] || lca_t == t) {
					if(dep[lca_t]<dep[lca_i]) {
						st.pop();
						continue;
					}
					else {
						if(lca_t !=t) {
							st.pop();
							continue;
						}
					}
				}
				else {
					if(out[a[i]]>out[t]) {
						st.pop();
						continue;
					}
				}
			}
			break;
		}
		f[i] = st.size();
		//printf("i = %d f i = %d\n",i,f[i]);
		st.push(a[i]);
	}

	dp[1][1] = 1;
	for(int i = 2; i <= k; ++i) {
		for(int j = 1; j <=m; ++j) {
			dp[i][j] = (dp[i-1][j-1] + dp[i-1][j]*(j-f[i-1]))%mod;
			//printf("i = %d j = %d dp = %d f = %d\n",i,j,dp[i][j], f[i-1]);
		}
	}
	ll ans = 0;
	for(int i = 1; i<=m;++i) {
		ans = (ans + dp[k][i])%mod;
	}
	return ans;
}

int main(){
	while(cin>>n>>q){
		fr(i,0,n-1) {
			int u,v;
			sf("%d%d",&u,&v);
			g[u].pb(v);
			g[v].pb(u);
		}
		id = 0;
		dfs(1,1);
		/*
		for(int i = 0; i < id; ++i) {
			printf("%d ",path[i]);
		}
		for(int i = 1;i <=n; ++i) {
			printf("i = %d in = %d out = %d\n",i,in[i],out[i]);
		}
		*/
		init();
		fr(i,0,q) {
			sf("%d%d%d",&k,&m,&r);
			for(int j = 0; j < k; ++j) {
				sf("%d",&a[j]);
			}
			cout<<sol()<<endl;
		}
	}
}


#include <string.h>
#include <unordered_map>

#include <sstream>
#include <stdio.h>
#include <assert.h>
#include <math.h>
#include <bitset>
#include <algorithm>
#include <iostream>
#include   <stdlib.h>
#include   <time.h>
#include <stack>
#include <queue>
#include <set>

#include <map>
#include <vector>
#include <string>
#include <stdlib.h>

#define ll long long
#define clr(x) memset(x,0,sizeof(x))
#define _clr(x) memset(x,-1,sizeof(x))
#define fr(i,a,b) for(int i = a; i < b; ++i)
#define frr(i,a,b) for(int i = a; i > b; --i)
#define pb push_back
#define sf scanf

#define pf printf
#define mp make_pair

using namespace std;
ll mod = 1000000007;
int n,q;

struct Edge{
	int a,b,next;
	Edge(){}
	Edge(int a, int b, int next):a(a),b(b),next(next){}
}e[1000010];

int p[1000010];
int tot;

void add(int a, int b) {
	e[tot] = Edge(a,b,p[a]);
	p[a]=tot++;
}

vector<int> g[1000010];
int in[1000010],out[1000010],path[1000010],id;
int f[100010],la[1000010][21];
int fa[1000010],dep[1000010];
int a[1000010];
ll dp[2][301];

void dfs(int t, int f) {
	fa[t] = f;
	path[id]=t;
	in[t] = id++;
	dep[t] = dep[f]+1;

	for(int i : g[t]) {
		if(i==f)continue;
		dfs(i,t);
	}

	path[id] = t;
	out[t] = id++;
}

void init() {
	for(int i = 1; i <=n; ++i) {
		la[i][0] = fa[i];
		//printf("i = %d fa = %d\n",i,fa[i]);
	}

	for(int j = 1; j <=20; ++j) {
		for(int i = 1; i <=n; ++i) {
			la[i][j] = la[ la[i][j-1] ][j-1];
			//printf("i = %d j = %d laj-1 = %d la = %d\n",i,j,la[i][j-1],la[i][j]);
		}
	}
}

int lca(int a, int b) {

	if(dep[a]<dep[b])swap(a,b);
	//printf("lca a = %d b = %d, depa = %d depb = %d\n",a,b,dep[a],dep[b]);
	for(int i = 20; i >=0;--i) {
		if(dep[la[a][i]]>=dep[b]) {
			//printf("a = %d i = %d la = %d\n",a,i,la[a][i]);
			a = la[a][i];
		}
	}
	if(a==b)return a;
	//printf("a = %d b = %d\n",a,b);
	for(int i = 20; i >=0; --i) {
		//printf("i = %d a = %d b = %d f = %d %d\n",i,a,b,la[a][i],la[b][i]);
		if(la[a][i]!=la[b][i]) {
			//printf("i = %d a = %d b = %d f = %d %d\n",i,a,b,la[a][i],la[b][i]);
			a = la[a][i];
			b = la[b][i];
		}
	}
	//printf("a = %d b = %d\n",a,b);
	return la[a][0];
}

int k,m,r;
int v[1000010];
int num;
vector<int> nima;

void dfs1(int t, int fa) {
	//printf("dfs1 t = %d fa = %d num = %d %d\n",t,fa,num,v[t]);
	f[t] = num;
	if(v[t]){
		nima.pb(t);
		++num;
	}
	for(int i = p[t]; i !=-1; i = e[i].next) {
		if(e[i].b==fa)continue;
		dfs1(e[i].b,t);
	}

	if(v[t])--num;
}
int sol() {

	clr(v);
	auto cmp = [&](const int i, int j) {
		return in[i]<in[j];
	};

	for(int i = 0; i < k; ++i) {
		v[a[i]]=1;
	}
	if(v[r]==0) {
		a[k++]=r;
	}

	sort(a,a+k,cmp);

	int flag = 0;
	set<int> sb;
	vector<int> ft;
	for(int i = 0; i < k; ++i) {
		if(i==0) {
			ft.pb(a[i]);
			sb.insert(a[i]);
		}
		else {
			int lca_i = lca(a[i],a[i-1]);
			//printf("lca i = %d i-1 = %d lca = %d\n",a[i],a[i-1],lca_i);
			if(sb.find(lca_i)==sb.end()) {
				sb.insert(lca_i);
				ft.pb(lca_i);
			}
			sb.insert(a[i]);
			ft.pb(a[i]);
		}
	}

	sort(ft.begin(), ft.end(),cmp);
	stack<int> st;

	_clr(p);
	tot = 0;
	for(int i = 0; i < ft.size();++i) {
		//printf("ft i = %d ft = %d\n",i,ft[i]);
		while(!st.empty()&&lca(ft[i],st.top())!=st.top()) st.pop();
		if(st.size()){
			//printf("add %d %d\n",ft[i],st.top());
			add(ft[i],st.top());
			add(st.top(),ft[i]);
		}
		st.push(ft[i]);
	}
	num = 0;
	nima.clear();
	dfs1(r,r);

	clr(dp);
	dp[1][1] = 1;
	//printf("i = 0 a = %d\n",nima[0]);
	for(int i = 2; i <= nima.size(); ++i) {
		int index = i&1;
		int pre = index ^1;
		clr(dp[index]);
		for(int j = 1; j <=m; ++j) {
			dp[index][j] = (dp[pre][j-1] + dp[pre][j]*(j-f[nima[i-1]]))%mod;
			//printf("i = %d j = %d a = %d dp = %lld f = %d\n",i,j,nima[i-1],dp[index][j], f[nima[i-1]]);
		}
	}
	ll ans = 0;
	for(int i = 1; i<=m;++i) {
		ans = (ans + dp[(nima.size())&1][i])%mod;
	}
	return ans;
}

int main(){
	while(cin>>n>>q){
		fr(i,0,n-1) {
			int u,v;
			sf("%d%d",&u,&v);
			g[u].pb(v);
			g[v].pb(u);
		}
		id = 0;
		dfs(1,1);
		/*
		for(int i = 0; i < id; ++i) {
			printf("%d ",path[i]);
		}
		for(int i = 1;i <=n; ++i) {
			printf("i = %d in = %d out = %d\n",i,in[i],out[i]);
		}
		*/
		init();
		fr(i,0,q) {
			sf("%d%d%d",&k,&m,&r);
			for(int j = 0; j < k; ++j) {
				sf("%d",&a[j]);
			}
			cout<<sol()<<endl;
		}
	}
}


#include <string.h>
#include <unordered_map>

#include <sstream>
#include <stdio.h>
#include <assert.h>
#include <math.h>
#include <bitset>
#include <algorithm>
#include <iostream>
#include   <stdlib.h>
#include   <time.h>
#include <stack>
#include <queue>
#include <set>

#include <map>
#include <vector>
#include <string>
#include <stdlib.h>

#define ll long long
#define clr(x) memset(x,0,sizeof(x))
#define _clr(x) memset(x,-1,sizeof(x))
#define fr(i,a,b) for(int i = a; i < b; ++i)
#define frr(i,a,b) for(int i = a; i > b; --i)
#define pb push_back
#define sf scanf

#define pf printf
#define mp make_pair

using namespace std;
ll mod = 1000000007;
int n,q;

struct Edge{
	int a,b,next;
	Edge(){}
	Edge(int a, int b, int next):a(a),b(b),next(next){}
}e[1000010];

int p[1000010];
int tot;

void add(int a, int b) {
	e[tot] = Edge(a,b,p[a]);
	p[a]=tot++;
}

vector<int> g[1000010];
int in[1000010],out[1000010],path[1000010],id;
int f[100010],la[1000010][21];
int fa[1000010],dep[1000010];
int a[1000010];
ll dp[2][301];

void dfs(int t, int f) {
	fa[t] = f;
	path[id]=t;
	in[t] = id++;
	dep[t] = dep[f]+1;

	for(int i : g[t]) {
		if(i==f)continue;
		dfs(i,t);
	}

	path[id] = t;
	out[t] = id++;
}

void init() {
	for(int i = 1; i <=n; ++i) {
		la[i][0] = fa[i];
		//printf("i = %d fa = %d\n",i,fa[i]);
	}

	for(int j = 1; j <=20; ++j) {
		for(int i = 1; i <=n; ++i) {
			la[i][j] = la[ la[i][j-1] ][j-1];
			//printf("i = %d j = %d laj-1 = %d la = %d\n",i,j,la[i][j-1],la[i][j]);
		}
	}
}

int lca(int a, int b) {

	if(dep[a]<dep[b])swap(a,b);
	//printf("lca a = %d b = %d, depa = %d depb = %d\n",a,b,dep[a],dep[b]);
	for(int i = 20; i >=0;--i) {
		if(dep[la[a][i]]>=dep[b]) {
			//printf("a = %d i = %d la = %d\n",a,i,la[a][i]);
			a = la[a][i];
		}
	}
	if(a==b)return a;
	//printf("a = %d b = %d\n",a,b);
	for(int i = 20; i >=0; --i) {
		//printf("i = %d a = %d b = %d f = %d %d\n",i,a,b,la[a][i],la[b][i]);
		if(la[a][i]!=la[b][i]) {
			//printf("i = %d a = %d b = %d f = %d %d\n",i,a,b,la[a][i],la[b][i]);
			a = la[a][i];
			b = la[b][i];
		}
	}
	//printf("a = %d b = %d\n",a,b);
	return la[a][0];
}

int k,m,r;
int v[1000010];
int num;
stack<int> stt;
vector<int> nima;

void dfs1(int t, int fa) {
	//printf("dfs1 t = %d fa = %d num = %d %d\n",t,fa,num,v[t]);
	f[t] = num;
	if(v[t]){
		nima.pb(t);
		++num;
	}
	stt.push(t);
	for(int i = p[t]; i !=-1; i = e[i].next) {
		if(e[i].b==fa)continue;
		dfs1(e[i].b,t);
	}

	if(v[t])--num;
	stt.pop();
}
int sol() {

	clr(v);
	auto cmp = [&](const int i, int j) {
		return in[i]<in[j];
	};

	sort(a,a+k,cmp);

	int flag = 0;
	set<int> sb;
	vector<int> ft;
	for(int i = 0; i < k; ++i) {
		v[a[i]]=1;
		if(i==0) {
			ft.pb(a[i]);
			sb.insert(a[i]);
		}
		else {
			int lca_i = lca(a[i],a[i-1]);
			if(sb.find(lca_i)==sb.end()) {
				sb.insert(lca_i);
				ft.pb(lca_i);
			}
			sb.insert(a[i]);
			ft.pb(a[i]);
		}
	}
	if(sb.find(r)==sb.end()) {
		sb.insert(r);
		ft.pb(r);
	}

	sort(ft.begin(), ft.end(),cmp);
	stack<int> st;

	_clr(p);
	tot = 0;
	for(int i = 0; i < ft.size();++i) {
		//printf("ft i = %d ft = %d\n",i,ft[i]);
		while(!st.empty()&&lca(ft[i],st.top())!=st.top()) st.pop();
		if(st.size()){
			//printf("add %d %d\n",ft[i],st.top());
			add(ft[i],st.top());
			add(st.top(),ft[i]);
		}
		st.push(ft[i]);
	}
	num = 0;
	nima.clear();
	dfs1(r,r);

	dp[1][1] = 1;
	for(int i = 2; i <= nima.size(); ++i) {
		int index = i&1;
		int pre = index ^1;
		clr(dp[index]);
		for(int j = 1; j <=m; ++j) {
			dp[index][j] = (dp[pre][j-1] + dp[pre][j]*(j-f[nima[i-1]]))%mod;
			//printf("i = %d j = %d a = %d dp = %lld f = %d\n",i,j,nima[i-1],dp[index][j], f[nima[i-1]]);
		}
	}
	ll ans = 0;
	for(int i = 1; i<=m;++i) {
		ans = (ans + dp[k&1][i])%mod;
	}
	return ans;
}

int main(){
	while(cin>>n>>q){
		fr(i,0,n-1) {
			int u,v;
			sf("%d%d",&u,&v);
			g[u].pb(v);
			g[v].pb(u);
		}
		id = 0;
		dfs(1,1);
		/*
		for(int i = 0; i < id; ++i) {
			printf("%d ",path[i]);
		}
		for(int i = 1;i <=n; ++i) {
			printf("i = %d in = %d out = %d\n",i,in[i],out[i]);
		}
		*/
		init();
		fr(i,0,q) {
			sf("%d%d%d",&k,&m,&r);
			for(int j = 0; j < k; ++j) {
				sf("%d",&a[j]);
			}
			cout<<sol()<<endl;
		}
	}
}


#include <string.h>
#include <unordered_map>

#include <sstream>
#include <stdio.h>
#include <assert.h>
#include <math.h>
#include <bitset>
#include <algorithm>
#include <iostream>
#include   <stdlib.h>
#include   <time.h>
#include <stack>
#include <queue>
#include <set>

#include <map>
#include <vector>
#include <string>
#include <stdlib.h>

#define ll long long
#define clr(x) memset(x,0,sizeof(x))
#define _clr(x) memset(x,-1,sizeof(x))
#define fr(i,a,b) for(int i = a; i < b; ++i)
#define frr(i,a,b) for(int i = a; i > b; --i)
#define pb push_back
#define sf scanf

#define pf printf
#define mp make_pair

using namespace std;
ll mod = 1000000007;
int n,q;

vector<int> g[1000010];
int in[1000010],out[1000010],path[1000010],id;
int f[100010],la[1000010][21];
int fa[1000010],dep[1000010];
int a[1000010];
int dp[100010][301];

void dfs(int t, int f) {
	fa[t] = f;
	path[id]=t;
	in[t] = id++;
	dep[t] = dep[f]+1;

	for(int i : g[t]) {
		if(i==f)continue;
		dfs(i,t);
	}

	path[id] = t;
	out[t] = id++;
}

void init() {
	for(int i = 1; i <=n; ++i) {
		la[i][0] = fa[i];
		//printf("i = %d fa = %d\n",i,fa[i]);
	}

	for(int j = 1; j <=20; ++j) {
		for(int i = 1; i <=n; ++i) {
			la[i][j] = la[ la[i][j-1] ][j-1];
			//printf("i = %d j = %d laj-1 = %d la = %d\n",i,j,la[i][j-1],la[i][j]);
		}
	}
}

int lca(int a, int b) {

	if(dep[a]<dep[b])swap(a,b);
	//printf("lca a = %d b = %d, depa = %d depb = %d\n",a,b,dep[a],dep[b]);
	for(int i = 20; i >=0;--i) {
		if(dep[la[a][i]]>=dep[b]) {
			//printf("a = %d i = %d la = %d\n",a,i,la[a][i]);
			a = la[a][i];
		}
	}
	//printf("a = %d b = %d\n",a,b);
	for(int i = 20; i >=0; --i) {
		//printf("i = %d a = %d b = %d f = %d %d\n",i,a,b,la[a][i],la[b][i]);
		if(la[a][i]!=la[b][i]) {
			//printf("i = %d a = %d b = %d f = %d %d\n",i,a,b,la[a][i],la[b][i]);
			a = la[a][i];
			b = la[b][i];
		}
	}
	//printf("a = %d b = %d\n",a,b);
	return la[a][0];
}

int k,m,r;

int sol() {

	auto cmp = [&](const int i, int j) {
		int lca_i = lca(i,r);
		int lca_j = lca(j,r);
		//printf("sort r = %d i = %d lca_I = %d j = %d lca_j = %d\n",r,i,lca_i,j,lca_j);
		if(lca_i==r&&lca_j==r) {
			return in[i]<in[j];
		}
		else if(lca_i==r&&lca_j!=r) {
			return false;
		}else if(lca_i!=r&&lca_j==r) {
			return true;
		}
		else {
			if(lca_i==i||lca_j==j) {
				return dep[lca_i]>dep[lca_j];
			}
			else {
				return in[i]<in[j];
			}
		}
	};

	sort(a,a+k,cmp);

	stack<int> st;
	for(int i = 0; i < k; ++i) {
		int lca_i = lca(a[i],r);
		//printf("i = %d a = %d r = %d lca = %d\n",i,a[i],r,lca_i);
		while(!st.empty()) {
			int t = st.top();
			int lca_t = lca(t,r);
			//printf("st t = %d r = %d lca = %d\n",t,r,lca_t);
			if(lca_t == r && lca_i == r) {
				if(out[a[i]]>out[t]) {
					st.pop();
					continue;
				}
			}
			else if(lca_t==r &&lca_i!=r) {
				break;
			}
			else if(lca_t!=r && lca_i==r) {
				st.pop();
				continue;
			}
			else {
				if(lca_i == a[i] || lca_t == t) {
					if(dep[lca_t]<dep[lca_i]) {
						st.pop();
						continue;
					}
					else {
						if(lca_t !=t) {
							st.pop();
							continue;
						}
					}
				}
				else {
					if(out[a[i]]>out[t]) {
						st.pop();
						continue;
					}
				}
			}
			break;
		}
		f[i] = st.size();
		//printf("i = %d f i = %d\n",i,f[i]);
		st.push(a[i]);
	}

	dp[1][1] = 1;
	for(int i = 2; i <= k; ++i) {
		for(int j = 1; j <=m; ++j) {
			dp[i][j] = (dp[i-1][j-1] + dp[i-1][j]*(j-f[i-1]))%mod;
			//printf("i = %d j = %d dp = %d f = %d\n",i,j,dp[i][j], f[i-1]);
		}
	}
	ll ans = 0;
	for(int i = 1; i<=m;++i) {
		ans = (ans + dp[k][i])%mod;
	}
	return ans;
}

int main(){
	while(cin>>n>>q){
		fr(i,0,n-1) {
			int u,v;
			sf("%d%d",&u,&v);
			g[u].pb(v);
			g[v].pb(u);
		}
		id = 0;
		dfs(1,1);
		/*
		for(int i = 0; i < id; ++i) {
			printf("%d ",path[i]);
		}
		for(int i = 1;i <=n; ++i) {
			printf("i = %d in = %d out = %d\n",i,in[i],out[i]);
		}
		*/
		init();
		fr(i,0,q) {
			sf("%d%d%d",&k,&m,&r);
			for(int j = 0; j < k; ++j) {
				sf("%d",&a[j]);
			}
			cout<<sol()<<endl;
		}
	}
}


#include <string.h>
#include <unordered_map>

#include <sstream>
#include <stdio.h>
#include <assert.h>
#include <math.h>
#include <bitset>
#include <algorithm>
#include <iostream>
#include   <stdlib.h>
#include   <time.h>
#include <stack>
#include <queue>
#include <set>

#include <map>
#include <vector>
#include <string>
#include <stdlib.h>

#define ll long long
#define clr(x) memset(x,0,sizeof(x))
#define _clr(x) memset(x,-1,sizeof(x))
#define fr(i,a,b) for(int i = a; i < b; ++i)
#define frr(i,a,b) for(int i = a; i > b; --i)
#define pb push_back
#define sf scanf

#define pf printf
#define mp make_pair

using namespace std;
ll mod = 1000000007;
int n,q;

vector<int> g[1000010];
int in[1000010],out[1000010],path[1000010],id;
int f[100010],la[1000010][21];
int fa[1000010],dep[1000010];
int a[1000010];
ll dp[2][301];

void dfs(int t, int f) {
	fa[t] = f;
	path[id]=t;
	in[t] = id++;
	dep[t] = dep[f]+1;

	for(int i : g[t]) {
		if(i==f)continue;
		dfs(i,t);
	}

	path[id] = t;
	out[t] = id++;
}

void init() {
	for(int i = 1; i <=n; ++i) {
		la[i][0] = fa[i];
		//printf("i = %d fa = %d\n",i,fa[i]);
	}

	for(int j = 1; j <=20; ++j) {
		for(int i = 1; i <=n; ++i) {
			la[i][j] = la[ la[i][j-1] ][j-1];
			//printf("i = %d j = %d laj-1 = %d la = %d\n",i,j,la[i][j-1],la[i][j]);
		}
	}
}

int lca(int a, int b) {

	if(dep[a]<dep[b])swap(a,b);
	//printf("lca a = %d b = %d, depa = %d depb = %d\n",a,b,dep[a],dep[b]);
	for(int i = 20; i >=0;--i) {
		if(dep[la[a][i]]>=dep[b]) {
			//printf("a = %d i = %d la = %d\n",a,i,la[a][i]);
			a = la[a][i];
		}
	}
	//printf("a = %d b = %d\n",a,b);
	for(int i = 20; i >=0; --i) {
		//printf("i = %d a = %d b = %d f = %d %d\n",i,a,b,la[a][i],la[b][i]);
		if(la[a][i]!=la[b][i]) {
			//printf("i = %d a = %d b = %d f = %d %d\n",i,a,b,la[a][i],la[b][i]);
			a = la[a][i];
			b = la[b][i];
		}
	}
	//printf("a = %d b = %d\n",a,b);
	return la[a][0];
}

int k,m,r;

int sol() {

	auto cmp = [&](const int i, int j) {
		int lca_i = lca(i,r);
		int lca_j = lca(j,r);
		//printf("sort r = %d i = %d lca_I = %d j = %d lca_j = %d\n",r,i,lca_i,j,lca_j);
		if(lca_i==r&&lca_j==r) {
			return in[i]<in[j];
		}
		else if(lca_i==r&&lca_j!=r) {
			return false;
		}else if(lca_i!=r&&lca_j==r) {
			return true;
		}
		else {
			if(lca_i==lca_j) {
				return in[i]<in[j];
			}
			else if(lca_i==i||lca_j==j) {
				return dep[lca_i]>dep[lca_j];
			}
			else {
				return in[i]<in[j];
			}
		}
	};

	sort(a,a+k,cmp);

	stack<int> st;
	for(int i = 0; i < k; ++i) {
		int lca_i = lca(a[i],r);
		//printf("i = %d a = %d r = %d lca = %d\n",i,a[i],r,lca_i);
		while(!st.empty()) {
			int t = st.top();
			int lca_t = lca(t,r);
			//printf("st t = %d r = %d lca = %d\n",t,r,lca_t);
			if(lca_t == r && lca_i == r) {
				if(out[a[i]]>out[t]) {
					st.pop();
					continue;
				}
			}
			else if(lca_t==r &&lca_i!=r) {
				break;
			}
			else if(lca_t!=r && lca_i==r) {
				st.pop();
				continue;
			}
			else {
				if(lca_i==lca_t) {
					if(out[a[i]]>out[t]) {
						st.pop();
						continue;
					}
				}
				else if(lca_i == a[i] || lca_t == t) {
					if(dep[lca_t]<dep[lca_i]) {
						st.pop();
						continue;
					}
					else {
						if(lca_t !=t) {
							st.pop();
							continue;
						}
					}
				}
				else {
					if(out[a[i]]>out[t]) {
						st.pop();
						continue;
					}
				}
			}
			break;
		}
		f[i] = st.size();
		//printf("i = %d f i = %d\n",i,f[i]);
		st.push(a[i]);
	}

	dp[1][1] = 1;
	int index = 2;
	for(int i = 2; i <= k; ++i) {
		int pre = index ^1;
		clr(dp[index]);
		for(int j = 1; j <=m; ++j) {
			dp[index][j] = (dp[pre][j-1] + dp[pre][j]*(j-f[i-1]))%mod;
			//printf("i = %d j = %d dp = %d f = %d\n",i,j,dp[i][j], f[i-1]);
		}
	}
	ll ans = 0;
	for(int i = 1; i<=m;++i) {
		ans = (ans + dp[k&1][i])%mod;
	}
	return ans;
}

int main(){
	while(cin>>n>>q){
		fr(i,0,n-1) {
			int u,v;
			sf("%d%d",&u,&v);
			g[u].pb(v);
			g[v].pb(u);
		}
		id = 0;
		dfs(1,1);
		/*
		for(int i = 0; i < id; ++i) {
			printf("%d ",path[i]);
		}
		for(int i = 1;i <=n; ++i) {
			printf("i = %d in = %d out = %d\n",i,in[i],out[i]);
		}
		*/
		init();
		fr(i,0,q) {
			sf("%d%d%d",&k,&m,&r);
			for(int j = 0; j < k; ++j) {
				sf("%d",&a[j]);
			}
			cout<<sol()<<endl;
		}
	}
}


#include <string.h>
#include <unordered_map>

#include <sstream>
#include <stdio.h>
#include <assert.h>
#include <math.h>
#include <bitset>
#include <algorithm>
#include <iostream>
#include   <stdlib.h>
#include   <time.h>
#include <stack>
#include <queue>
#include <set>

#include <map>
#include <vector>
#include <string>
#include <stdlib.h>

#define ll long long
#define clr(x) memset(x,0,sizeof(x))
#define _clr(x) memset(x,-1,sizeof(x))
#define fr(i,a,b) for(int i = a; i < b; ++i)
#define frr(i,a,b) for(int i = a; i > b; --i)
#define pb push_back
#define sf scanf

#define pf printf
#define mp make_pair

using namespace std;
ll mod = 1000000007;
int n,q;

struct Edge{
	int a,b,next;
	Edge(){}
	Edge(int a, int b, int next):a(a),b(b),next(next){}
}e[1000010];

int p[100010];
int tot;

void add(int a, int b) {
	e[tot] = Edge(a,b,p[a]);
	p[a]=tot++;
}

vector<int> g[1000010];
int in[1000010],out[1000010],path[1000010],id;
int f[100010],la[1000010][21];
int fa[1000010],dep[1000010];
int a[1000010];
ll dp[2][301];

void dfs(int t, int f) {
	fa[t] = f;
	path[id]=t;
	in[t] = id++;
	dep[t] = dep[f]+1;

	for(int i : g[t]) {
		if(i==f)continue;
		dfs(i,t);
	}

	path[id] = t;
	out[t] = id++;
}

void init() {
	for(int i = 1; i <=n; ++i) {
		la[i][0] = fa[i];
		//printf("i = %d fa = %d\n",i,fa[i]);
	}

	for(int j = 1; j <=20; ++j) {
		for(int i = 1; i <=n; ++i) {
			la[i][j] = la[ la[i][j-1] ][j-1];
			//printf("i = %d j = %d laj-1 = %d la = %d\n",i,j,la[i][j-1],la[i][j]);
		}
	}
}

int lca(int a, int b) {

	if(dep[a]<dep[b])swap(a,b);
	//printf("lca a = %d b = %d, depa = %d depb = %d\n",a,b,dep[a],dep[b]);
	for(int i = 20; i >=0;--i) {
		if(dep[la[a][i]]>=dep[b]) {
			//printf("a = %d i = %d la = %d\n",a,i,la[a][i]);
			a = la[a][i];
		}
	}
	if(a==b)return a;
	//printf("a = %d b = %d\n",a,b);
	for(int i = 20; i >=0; --i) {
		//printf("i = %d a = %d b = %d f = %d %d\n",i,a,b,la[a][i],la[b][i]);
		if(la[a][i]!=la[b][i]) {
			//printf("i = %d a = %d b = %d f = %d %d\n",i,a,b,la[a][i],la[b][i]);
			a = la[a][i];
			b = la[b][i];
		}
	}
	//printf("a = %d b = %d\n",a,b);
	return la[a][0];
}

int k,m,r;
int v[100010];
int num;
vector<int> nima;

void dfs1(int t, int fa) {
	//printf("dfs1 t = %d fa = %d num = %d %d\n",t,fa,num,v[t]);
	f[t] = num;
	if(v[t]){
		nima.pb(t);
		++num;
	}
	for(int i = p[t]; i !=-1; i = e[i].next) {
		if(e[i].b==fa)continue;
		dfs1(e[i].b,t);
	}

	if(v[t])--num;
}
int sol() {

	clr(v);
	auto cmp = [&](const int i, int j) {
		return in[i]<in[j];
	};

	for(int i = 0; i < k; ++i) {
		v[a[i]]=1;
	}
	if(v[r]==0) {
		a[k++]=r;
	}

	sort(a,a+k,cmp);

	int flag = 0;
	set<int> sb;
	vector<int> ft;
	for(int i = 0; i < k; ++i) {
		if(i==0) {
			ft.pb(a[i]);
			sb.insert(a[i]);
		}
		else {
			int lca_i = lca(a[i],a[i-1]);
			//printf("lca i = %d i-1 = %d lca = %d\n",a[i],a[i-1],lca_i);
			if(sb.find(lca_i)==sb.end()) {
				sb.insert(lca_i);
				ft.pb(lca_i);
			}
			sb.insert(a[i]);
			ft.pb(a[i]);
		}
	}

	sort(ft.begin(), ft.end(),cmp);
	stack<int> st;

	_clr(p);
	tot = 0;
	for(int i = 0; i < ft.size();++i) {
		//printf("ft i = %d ft = %d\n",i,ft[i]);
		while(!st.empty()&&lca(ft[i],st.top())!=st.top()) st.pop();
		if(st.size()){
			//printf("add %d %d\n",ft[i],st.top());
			add(ft[i],st.top());
			add(st.top(),ft[i]);
		}
		st.push(ft[i]);
	}
	num = 0;
	nima.clear();
	dfs1(r,r);

	clr(dp);
	dp[1][1] = 1;
	//printf("i = 0 a = %d\n",nima[0]);
	for(int i = 2; i <= nima.size(); ++i) {
		int index = i&1;
		int pre = index ^1;
		clr(dp[index]);
		for(int j = 1; j <=m; ++j) {
			dp[index][j] = (dp[pre][j-1] + dp[pre][j]*(j-f[nima[i-1]]))%mod;
			//printf("i = %d j = %d a = %d dp = %lld f = %d\n",i,j,nima[i-1],dp[index][j], f[nima[i-1]]);
		}
	}
	ll ans = 0;
	for(int i = 1; i<=m;++i) {
		ans = (ans + dp[(nima.size())&1][i])%mod;
	}
	return ans;
}

int main(){
	while(cin>>n>>q){
		fr(i,0,n-1) {
			int u,v;
			sf("%d%d",&u,&v);
			g[u].pb(v);
			g[v].pb(u);
		}
		id = 0;
		dfs(1,1);
		/*
		for(int i = 0; i < id; ++i) {
			printf("%d ",path[i]);
		}
		for(int i = 1;i <=n; ++i) {
			printf("i = %d in = %d out = %d\n",i,in[i],out[i]);
		}
		*/
		init();
		fr(i,0,q) {
			sf("%d%d%d",&k,&m,&r);
			for(int j = 0; j < k; ++j) {
				sf("%d",&a[j]);
			}
			cout<<sol()<<endl;
		}
	}
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <string.h>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
//head

const int N = 1e5+10;
int n, q;
vector<int> g[N];
int top[N], fa[N], dep[N], son[N];
int L[N], R[N], sz[N];

int calc(int x, int y, int f) {
    int pre = 0, lca;
    while (top[x]!=top[y]) {
        if (dep[top[x]]<dep[top[y]]) swap(x,y);
        pre = top[x];
        x = fa[pre];
    }
    if (x==y) lca=x;
    else lca=dep[x]<dep[y]?x:y;
    if (lca!=f) return 0;
    if (fa[pre]==f) return pre;
    return son[f];
}

void dfs(int x, int f, int d) {
    L[x]=++*L,sz[x]=1,fa[x]=f,dep[x]=d;
    int mx = -1;
    for (int y:g[x]) if (y!=f) {
        dfs(y,x,d+1),sz[x]+=sz[y];
        if (mx<sz[y]) mx=sz[y],son[x]=y;
    }
    R[x]=*L;
}
void dfs2(int x, int tf) {
    top[x]=tf;
    if (son[x]) dfs2(son[x],tf);
    for (int y:g[x]) if (y!=fa[x]&&y!=son[x]) dfs2(y,y);
}
int c[N];
void add(int x, int v) {
    for (; x<=n; x+=x&-x) c[x]+=v;
}
void update(int l, int r, int v) {
    add(l,v),add(r+1,-v);
}
int query(int x) {
    int r = 0;
    for (; x; x^=x&-x) r+=c[x];
    return r;
}
struct _ {
    int x,c,f;
} a[N];
int dp[N][322];

int main() {
    scanf("%d%d", &n, &q);
    REP(i,2,n) {
        int u, v;
        scanf("%d%d", &u, &v);
        g[u].pb(v),g[v].pb(u);
    }
    dfs(1,0,0),dfs2(1,1);
    while (q--) {
        int k, m, r;
        scanf("%d%d%d", &k, &m, &r);
        REP(i,1,k) {
            scanf("%d", &a[i].x);
            if (a[i].x==r) {update(1,n,1);continue;}
            a[i].c = calc(a[i].x,r,a[i].x);
            if (!a[i].c) update(L[a[i].x],R[a[i].x],1);
            else update(1,n,1),update(L[a[i].c],R[a[i].c],-1);
        }
        REP(i,1,k) a[i].f = query(L[a[i].x]);
        sort(a+1,a+1+k,[](_ a,_ b){return a.f<b.f;});
        if (a[k].f<=m) {
            dp[0][0] = 1;
            REP(i,1,k) REP(j,a[i].f,m) {
                dp[i][j] = (dp[i-1][j-1]+(ll)(j-a[i].f+1)*dp[i-1][j])%P;
            }
            ll ans = 0;
            REP(i,a[k].f,m) ans+=dp[k][i];
            printf("%d\n", int(ans%P));
            REP(i,1,k) REP(j,a[i].f,m) dp[i][j]=0;
        }
        else puts("0");
        REP(i,1,k) {
            if (a[i].x==r) update(1,n,-1);
            else if (!a[i].c) update(L[a[i].x],R[a[i].x],-1);
            else update(1,n,-1),update(L[a[i].c],R[a[i].c],1);
        }
    }
}


#include <bits/stdc++.h>
#define ll long long
#define inc(i,l,r) for(int i=l;i<=r;i++)
const int MAXN=3e5+10;
using namespace std;
const ll inf=1e18;
const ll MOD=1e9+7;
vector<int>vec[MAXN];
int f[MAXN][21];int dep[MAXN];
int st[MAXN],tot;
int p[MAXN],cnt1;
vector<int>V;
bool vis[MAXN];
ll read(){
    ll x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return f*x;
}
ll Add(ll a, ll b){a+=b;if(a>=MOD)a-=MOD; return a;}
ll Mult(ll a, ll b){return (a*b)%MOD;}
void dfs(int v,int pre,int deep){
    dep[v]=deep;f[v][0]=pre;p[v]=++cnt1;
    for(int i=0;i<vec[v].size();i++){
    int u=vec[v][i];
    if(u!=pre){
        dfs(u,v,deep+1);
    }
    }
}
void dfs1(int v){
    inc(i,1,20)f[v][i]=f[f[v][i-1]][i-1];
    for(int i=0;i<vec[v].size();i++){
    int u=vec[v][i];
    if(u!=f[v][0])dfs1(u);
    }
}
int Lca(int u,int v){
    if(dep[u]<dep[v])swap(u,v);
    int tmp=dep[u]-dep[v];
    for(int i=0;i<=20;i++)if(tmp&(1<<i))u=f[u][i];
    if(u==v)return u;
    for(int i=20;i>=0;i--){
    if(f[u][i]!=f[v][i]){
        u=f[u][i];
        v=f[v][i];
    }
    }
    return f[u][0];
}
ll dp[2][305];
void built(int x){
    V.push_back(x);
    if(!tot){st[++tot]=x;return ;}
    int lca=Lca(x,st[tot]);
    while(tot>1&&dep[lca]<dep[st[tot-1]]){
    vec[st[tot]].push_back(st[tot-1]);
    vec[st[tot-1]].push_back(st[tot]);
    tot--;
    }
    if(dep[st[tot]]>dep[lca]){
    vec[st[tot]].push_back(lca);
    vec[lca].push_back(st[tot]);
    tot--;
    V.push_back(lca);
    }
    if(!tot||dep[lca]>dep[st[tot]])st[++tot]=lca;
    st[++tot]=x;
}
int M[MAXN],St[MAXN],cnt;
void dfs2(int x,int pre,int deep){
    if(vis[x])M[x]=deep+1,St[++cnt]=x;
    for(int i=0;i<vec[x].size();i++){
    if(vec[x][i]!=pre){
        if(vis[x])dfs2(vec[x][i],x,deep+1);
        else dfs2(vec[x][i],x,deep);
    }
    }
}
int n,m;
bool cmp(int aa,int bb){return p[aa]<p[bb];}
int main(){
    n=read();m=read();
    int u,v;
    for(int i=1;i<n;i++)u=read(),v=read(),vec[u].push_back(v),vec[v].push_back(u);
    dfs(1,0,0);dfs1(1);int k,q,r;
    for(int i=1;i<=n;i++)vec[i].clear();
    while(m--){
    k=read();q=read();r=read();
    tot=0;
    V.push_back(r);
    for(int i=1;i<=k;i++)v=read(),V.push_back(v),vis[v]=1;
    sort(V.begin(),V.end(),cmp);
    int sz=unique(V.begin(),V.end())-V.begin();
    for(int i=1;i<=sz;i++)built(V[i-1]);
    while(tot>1){vec[st[tot]].push_back(st[tot-1]),vec[st[tot-1]].push_back(st[tot]);tot--;}
    cnt=0;dfs2(r,0,0);
    int K=0;
    inc(i,1,q)dp[K][i]=0;
    dp[K][0]=1;
    for(int i=1;i<=cnt;i++){
    K=1-K;
    inc(j,0,q)dp[K][j]=0;
    for(int j=0;j<=q;j++){
        if(j<q)dp[K][j+1]=Add(dp[K][j+1],dp[!K][j]);
        if(M[St[i]]<=j)dp[K][j]=Add(dp[K][j],Mult(dp[!K][j],j-M[St[i]]+1));
    }
    }
    ll ans=0;
    inc(i,1,q)ans=Add(ans,dp[K][i]);
    printf("%lld\n",ans);
    for(int i=0;i<V.size();i++)vec[V[i]].clear(),vis[V[i]]=0;
    V.clear();
    }
    return 0;
}


#include <bits/stdc++.h>

const int MAXN = 1e5 + 10;
const int mod = 1e9 + 7;
typedef long long LL;
void reduce(int & x) { x += x >> 31 & mod; }
int mul(int a, int b) { return (LL) a * b % mod; }
int pow(int a, int b, int res = 1) {
	for (; b; b >>= 1, a = mul(a, a)) if (b & 1) res = mul(res, a);
	return res;
}
void fma(int & x, int y, int z) {
	x = ((LL) y * z + x) % mod;
}
void fms(int & x, int y, int z) {
	x = ((LL) (mod - y) * z + x) % mod;
}

int head[MAXN], nxt[MAXN << 1], to[MAXN << 1], tot;
void adde(int b, int e) {
	nxt[++tot] = head[b]; to[head[b] = tot] = e;
	nxt[++tot] = head[e]; to[head[e] = tot] = b;
}
int in[MAXN], out[MAXN], idx;
int ST[18][MAXN << 1];
void dfs(int u, int f = 0) {
	ST[0][++idx] = u;
	in[u] = idx;
	for (int i = head[u]; i; i = nxt[i])
		if (to[i] != f) {
			dfs(to[i], u);
			ST[0][++idx] = u;
		}
	out[u] = idx;
}
int gmi(int a, int b) {
	return in[a] < in[b] ? a : b;
}
int LCA(int a, int b) {
	a = in[a], b = in[b];
	if (a > b) std::swap(a, b);
	const int L = std::__lg(++b - a);
	return gmi(ST[L][a], ST[L][b - (1 << L)]);
}

namespace ex {
	int head[MAXN], nxt[MAXN << 1], to[MAXN << 1], tot;
	void adde(int b, int e) {
		nxt[++tot] = head[b]; to[head[b] = tot] = e;
		nxt[++tot] = head[e]; to[head[e] = tot] = b;
	}
	int imp[MAXN];
	void clr(int * li, int n) {
		tot = 0;
		for (int i = 1; i <= n; ++i) head[li[i]] = 0;
		for (int i = 1; i <= n; ++i) imp[li[i]] = 0;
	}
	int M;
	const int MAXL = 310;
	int dp[MAXN][MAXL];
	int C[MAXL][MAXL];
	const int BLO = 320;
	int pw[MAXL][MAXN];
	int ifac[MAXL];
	void init() {
		ifac[0] = ifac[1] = 1;
		for (int i = 2; i != MAXL; ++i)
			ifac[i] = mul(ifac[mod % i], mod - mod / i);
		for (int i = 2; i != MAXL; ++i)
			ifac[i] = mul(ifac[i - 1], ifac[i]);
		for (int i = 0; i != MAXL; ++i)
			for (int j = C[i][0] = 1; j <= i; ++j)
				reduce(C[i][j] = C[i - 1][j] + C[i - 1][j - 1] - mod);
		for (int i = 0; i != MAXL; ++i) {
			pw[i][0] = 1;
			for (int j = 1; j != MAXN; ++j)
				pw[i][j] = mul(pw[i][j - 1], i);
		}
	}
	int dep[MAXL], mad;
	void dfs(int u, int d = 0, int fa = 0) {
		if (imp[u]) {
			mad = std::max(mad, d);
			++dep[std::min(d++, MAXL - 1)];
		}
		for (int i = head[u]; i; i = nxt[i])
			if (to[i] != fa)
				dfs(to[i], d, u);
	}
	int f[MAXL], g[MAXL];
	int solve(int _M, int R) {
		M = _M;
		mad = 0;
		memset(dep, 0, M + 1 << 2);
		memset(f, 0, M + 1 << 2);
		dfs(R);
		if (mad >= M) return 0;
		for (int i = mad; i <= M; ++i) {
			int & t = f[i] = 1;
			for (int j = 0; j <= mad; ++j)
				t = mul(t, pw[i - j][dep[j]]);
		}
		int res = 0;
		for (int i = 0; i <= M; ++i) {
			g[i] = f[i];
			for (int j = 0; j < i; ++j)
				fms(g[i], g[j], C[i][j]);
			fma(res, g[i], ifac[i]);
		}
		return res;
	}
}
int n;
int main() {
	ex::init();
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	int Q; std::cin >> n >> Q;
	for (int i = 1, b, e; i < n; ++i)
		std::cin >> b >> e, adde(b, e);
	dfs(1);
	for (int i = 1; i != 18; ++i)
		for (int j = 1; j + (1 << i) - 1 <= idx; ++j)
			ST[i][j] = gmi(ST[i - 1][j], ST[i - 1][j + (1 << i - 1)]);
	auto cmp = [] (int a, int b) {
		return in[a] < in[b];
	};
	while (Q --> 0) {
		static int li[MAXN << 1];
		int K, M, R;
		std::cin >> K >> M >> R;
		int bak = K + 1; li[bak] = R;
		for (int i = 1; i <= K; ++i)
			std::cin >> li[i], ex::imp[li[i]] = true;
		std::sort(li + 1, li + 1 + bak, cmp);
		bak = std::unique(li + 1, li + 1 + bak) - li - 1;
		for (int i = bak; i > 1; --i)
			li[++bak] = LCA(li[i], li[i - 1]);
		std::sort(li + 1, li + 1 + bak, cmp);
		bak = std::unique(li + 1, li + 1 + bak) - li - 1;
		static int st[MAXN];
		int top = 0;
		for (int i = 1; i <= bak; ++i) {
			const int u = li[i];
			while (top && in[u] > out[st[top]])
				ex::adde(st[top], st[top - 1]), --top;
			assert(top || i == 1);
			st[++top] = u;
		}
		while (top > 1)
			ex::adde(st[top], st[top - 1]), --top;
		std::cout << ex::solve(M, R) << '\n';
		ex::clr(li, bak);
	}
	return 0;
}


#include <bits/stdc++.h>

const int MAXN = 1e5 + 10;
const int mod = 1e9 + 7;
typedef long long LL;
void reduce(int & x) { x += x >> 31 & mod; }
int mul(int a, int b) { return (LL) a * b % mod; }
int pow(int a, int b, int res = 1) {
	for (; b; b >>= 1, a = mul(a, a)) if (b & 1) res = mul(res, a);
	return res;
}
void fma(int & x, int y, int z) {
	x = ((LL) y * z + x) % mod;
}
void fms(int & x, int y, int z) {
	x = ((LL) (mod - y) * z + x) % mod;
}

int head[MAXN], nxt[MAXN << 1], to[MAXN << 1], tot;
void adde(int b, int e) {
	nxt[++tot] = head[b]; to[head[b] = tot] = e;
	nxt[++tot] = head[e]; to[head[e] = tot] = b;
}
int in[MAXN], out[MAXN], idx;
int ST[18][MAXN << 1];
void dfs(int u, int f = 0) {
	ST[0][++idx] = u;
	in[u] = idx;
	for (int i = head[u]; i; i = nxt[i])
		if (to[i] != f) {
			dfs(to[i], u);
			ST[0][++idx] = u;
		}
	out[u] = idx;
}
int gmi(int a, int b) {
	return in[a] < in[b] ? a : b;
}
int LCA(int a, int b) {
	a = in[a], b = in[b];
	if (a > b) std::swap(a, b);
	const int L = std::__lg(++b - a);
	return gmi(ST[L][a], ST[L][b - (1 << L)]);
}

namespace ex {
	int head[MAXN], nxt[MAXN << 1], to[MAXN << 1], tot;
	void adde(int b, int e) {
		nxt[++tot] = head[b]; to[head[b] = tot] = e;
		nxt[++tot] = head[e]; to[head[e] = tot] = b;
	}
	int imp[MAXN];
	void clr(int * li, int n) {
		tot = 0;
		for (int i = 1; i <= n; ++i) head[li[i]] = 0;
		for (int i = 1; i <= n; ++i) imp[li[i]] = 0;
	}
	int M;
	const int MAXL = 310;
	const int BLO = 320;
	int C[MAXL][MAXL];
	int ifac[MAXL];
	void init() {
		ifac[0] = ifac[1] = 1;
		for (int i = 2; i != MAXL; ++i)
			ifac[i] = mul(ifac[mod % i], mod - mod / i);
		for (int i = 2; i != MAXL; ++i)
			ifac[i] = mul(ifac[i - 1], ifac[i]);
		for (int i = 0; i != MAXL; ++i)
			for (int j = C[i][0] = 1; j <= i; ++j)
				reduce(C[i][j] = C[i - 1][j] + C[i - 1][j - 1] - mod);
	}
	int dep[MAXL], mad;
	void dfs(int u, int d = 0, int fa = 0) {
		if (imp[u]) {
			mad = std::max(mad, d);
			++dep[std::min(d++, MAXL - 1)];
		}
		for (int i = head[u]; i; i = nxt[i])
			if (to[i] != fa)
				dfs(to[i], d, u);
	}
	int f[MAXL], g[MAXL];
	int solve(int _M, int R) {
		M = _M;
		mad = 0;
		memset(dep, 0, M + 1 << 2);
		memset(f, 0, M + 1 << 2);
		dfs(R);
		if (mad >= M) return 0;
		for (int i = mad; i <= M; ++i) {
			int & t = f[i] = 1;
			for (int j = 0; j <= mad; ++j)
				t = pow(i - j, dep[j], t);
		}
		int res = 0;
		for (int i = 0; i <= M; ++i) {
			g[i] = f[i];
			for (int j = 0; j < i; ++j)
				fms(g[i], g[j], C[i][j]);
			fma(res, g[i], ifac[i]);
		}
		return res;
	}
}
int n;
int main() {
	ex::init();
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	int Q; std::cin >> n >> Q;
	for (int i = 1, b, e; i < n; ++i)
		std::cin >> b >> e, adde(b, e);
	dfs(1);
	for (int i = 1; i != 18; ++i)
		for (int j = 1; j + (1 << i) - 1 <= idx; ++j)
			ST[i][j] = gmi(ST[i - 1][j], ST[i - 1][j + (1 << i - 1)]);
	auto cmp = [] (int a, int b) {
		return in[a] < in[b];
	};
	while (Q --> 0) {
		static int li[MAXN << 1];
		int K, M, R;
		std::cin >> K >> M >> R;
		int bak = K + 1; li[bak] = R;
		for (int i = 1; i <= K; ++i)
			std::cin >> li[i], ex::imp[li[i]] = true;
		std::sort(li + 1, li + 1 + bak, cmp);
		bak = std::unique(li + 1, li + 1 + bak) - li - 1;
		for (int i = bak; i > 1; --i)
			li[++bak] = LCA(li[i], li[i - 1]);
		std::sort(li + 1, li + 1 + bak, cmp);
		bak = std::unique(li + 1, li + 1 + bak) - li - 1;
		static int st[MAXN];
		int top = 0;
		for (int i = 1; i <= bak; ++i) {
			const int u = li[i];
			while (top && in[u] > out[st[top]])
				ex::adde(st[top], st[top - 1]), --top;
			assert(top || i == 1);
			st[++top] = u;
		}
		while (top > 1)
			ex::adde(st[top], st[top - 1]), --top;
		std::cout << ex::solve(M, R) << '\n';
		ex::clr(li, bak);
	}
	return 0;
}


#include <bits/stdc++.h>

const int MAXN = 1e5 + 10;
const int mod = 1e9 + 7;
typedef long long LL;
void reduce(int & x) { x += x >> 31 & mod; }
int mul(int a, int b) { return (LL) a * b % mod; }
int pow(int a, int b, int res = 1) {
	for (; b; b >>= 1, a = mul(a, a)) if (b & 1) res = mul(res, a);
	return res;
}
void fma(int & x, int y, int z) {
	x = ((LL) y * z + x) % mod;
}
void fms(int & x, int y, int z) {
	x = ((LL) (mod - y) * z + x) % mod;
}

int head[MAXN], nxt[MAXN << 1], to[MAXN << 1], tot;
void adde(int b, int e) {
	nxt[++tot] = head[b]; to[head[b] = tot] = e;
	nxt[++tot] = head[e]; to[head[e] = tot] = b;
}
int in[MAXN], out[MAXN], idx;
int ST[18][MAXN << 1];
void dfs(int u, int f = 0) {
	ST[0][++idx] = u;
	in[u] = idx;
	for (int i = head[u]; i; i = nxt[i])
		if (to[i] != f) {
			dfs(to[i], u);
			ST[0][++idx] = u;
		}
	out[u] = idx;
}
int gmi(int a, int b) {
	return in[a] < in[b] ? a : b;
}
int LCA(int a, int b) {
	a = in[a], b = in[b];
	if (a > b) std::swap(a, b);
	const int L = std::__lg(++b - a);
	return gmi(ST[L][a], ST[L][b - (1 << L)]);
}

namespace ex {
	int head[MAXN], nxt[MAXN << 1], to[MAXN << 1], tot;
	void adde(int b, int e) {
		nxt[++tot] = head[b]; to[head[b] = tot] = e;
		nxt[++tot] = head[e]; to[head[e] = tot] = b;
	}
	int imp[MAXN];
	void clr(int * li, int n) {
		tot = 0;
		for (int i = 1; i <= n; ++i) head[li[i]] = 0;
		for (int i = 1; i <= n; ++i) imp[li[i]] = 0;
	}
	int M;
	const int MAXL = 310;
	const int BLO = 320;
	int C[MAXL][MAXL];
	int pw[MAXL][MAXN];
	int ifac[MAXL];
	void init() {
		ifac[0] = ifac[1] = 1;
		for (int i = 2; i != MAXL; ++i)
			ifac[i] = mul(ifac[mod % i], mod - mod / i);
		for (int i = 2; i != MAXL; ++i)
			ifac[i] = mul(ifac[i - 1], ifac[i]);
		for (int i = 0; i != MAXL; ++i)
			for (int j = C[i][0] = 1; j <= i; ++j)
				reduce(C[i][j] = C[i - 1][j] + C[i - 1][j - 1] - mod);
		for (int i = 0; i != MAXL; ++i) {
			pw[i][0] = 1;
			for (int j = 1; j != MAXN; ++j)
				pw[i][j] = mul(pw[i][j - 1], i);
		}
	}
	int dep[MAXL], mad;
	void dfs(int u, int d = 0, int fa = 0) {
		if (imp[u]) {
			mad = std::max(mad, d);
			++dep[std::min(d++, MAXL - 1)];
		}
		for (int i = head[u]; i; i = nxt[i])
			if (to[i] != fa)
				dfs(to[i], d, u);
	}
	int f[MAXL], g[MAXL];
	int solve(int _M, int R) {
		M = _M;
		mad = 0;
		memset(dep, 0, M + 1 << 2);
		memset(f, 0, M + 1 << 2);
		dfs(R);
		if (mad >= M) return 0;
		for (int i = mad; i <= M; ++i) {
			int & t = f[i] = 1;
			for (int j = 0; j <= mad; ++j)
				t = mul(t, pw[i - j][dep[j]]);
		}
		int res = 0;
		for (int i = 0; i <= M; ++i) {
			g[i] = f[i];
			for (int j = 0; j < i; ++j)
				fms(g[i], g[j], C[i][j]);
			fma(res, g[i], ifac[i]);
		}
		return res;
	}
}
int n;
int main() {
	ex::init();
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	int Q; std::cin >> n >> Q;
	for (int i = 1, b, e; i < n; ++i)
		std::cin >> b >> e, adde(b, e);
	dfs(1);
	for (int i = 1; i != 18; ++i)
		for (int j = 1; j + (1 << i) - 1 <= idx; ++j)
			ST[i][j] = gmi(ST[i - 1][j], ST[i - 1][j + (1 << i - 1)]);
	auto cmp = [] (int a, int b) {
		return in[a] < in[b];
	};
	while (Q --> 0) {
		static int li[MAXN << 1];
		int K, M, R;
		std::cin >> K >> M >> R;
		int bak = K + 1; li[bak] = R;
		for (int i = 1; i <= K; ++i)
			std::cin >> li[i], ex::imp[li[i]] = true;
		std::sort(li + 1, li + 1 + bak, cmp);
		bak = std::unique(li + 1, li + 1 + bak) - li - 1;
		for (int i = bak; i > 1; --i)
			li[++bak] = LCA(li[i], li[i - 1]);
		std::sort(li + 1, li + 1 + bak, cmp);
		bak = std::unique(li + 1, li + 1 + bak) - li - 1;
		static int st[MAXN];
		int top = 0;
		for (int i = 1; i <= bak; ++i) {
			const int u = li[i];
			while (top && in[u] > out[st[top]])
				ex::adde(st[top], st[top - 1]), --top;
			assert(top || i == 1);
			st[++top] = u;
		}
		while (top > 1)
			ex::adde(st[top], st[top - 1]), --top;
		std::cout << ex::solve(M, R) << '\n';
		ex::clr(li, bak);
	}
	return 0;
}


#include <cmath>
#include <ctime>
#include <cstdio>
#include <cctype>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <cassert>

#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <vector>
#include <string>
#include <complex>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

#define lson (k << 1)
#define rson (k << 1 | 1)
#define fi first
#define se second
#define pb push_back
#define lowbit(x) ((x) & -(x))
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " = " << (x) << endl
#define rep(i, s, t) for (int i = (s), _t = (t); i < _t; ++i)
#define per(i, s, t) for (int i = (t) - 1, _s = (s); i >= _s; --i)

using namespace std;

typedef double db;
typedef long long ll;
typedef vector<int> ivec;
typedef pair<int, int> pii;

template<class T> inline void Max(T &a, T b)
{
	if (b > a) a = b;
}

template<class T> inline void Min(T &a, T b)
{
	if (b < a) a = b;
}
// EOT

const int N = (int)1e5 + 5;

ivec edge[N];
int dep[N];
int par[N];
int sz[N];
int hv_son[N];
int tp[N];
int dfn[N], post[N];

void dfs(int u)
{
	sz[u] = 1;
	for (int v: edge[u])
	{
		if (v == par[u]) continue;
		par[v] = u;
		dep[v] = dep[u] + 1;
		dfs(v);
		sz[u] += sz[v];
		if (!hv_son[u] || sz[v] > sz[hv_son[u]]) hv_son[u] = v;
	}
}

void redfs(int u)
{
	static int dfs_clock = 0;
	dfn[u] = ++dfs_clock;
	if (hv_son[u])
	{
		tp[hv_son[u]] = tp[u];
		redfs(hv_son[u]);
	}
	for (int v: edge[u])
	{
		if (v == par[u] || v == hv_son[u]) continue;
		tp[v] = v;
		redfs(v);
	}
	post[u] = dfs_clock;
}

int lca(int u, int v)
{
	for (; tp[u] != tp[v]; u = par[tp[u]])
	{
		if (dep[tp[u]] < dep[tp[v]]) swap(u, v);
	}
	if (dep[u] > dep[v]) swap(u, v);
	return u;
}

inline int dist(int u, int v)
{
	return dep[u] + dep[v] - (dep[lca(u, v)] << 1);
}

int n;
int bit[N];

void bit_add_pref(int x, int val)
{
	for (; x; x -= lowbit(x))
		bit[x] += val;
}

void bit_add_itv(int L, int R, int val)
{
	bit_add_pref(R, val);
	bit_add_pref(L - 1, -val);
}

int bit_query_pos(int x)
{
	int res = 0;
	for (; x <= n; x += lowbit(x))
		res += bit[x];
	return res;
}

inline void upd_subtree(int u, int val)
{
	bit_add_itv(dfn[u], post[u], val);
}

inline int query_path_to_root(int u)
{
	return bit_query_pos(dfn[u]);
}

const int mod = (int)1e9 + 7;

void mod_add(int &a, int b)
{
	if ((a += b) >= mod) a -= mod;
}

const int M = 305;

int node[N];
int dis[N];
int dp[M];

bool cmp_dis(int u, int v)
{
	return dis[u] < dis[v];
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int q;
	cin >> n >> q;
	rep(i,0,n-1)
	{
		int u, v;
		cin >> u >> v;
		edge[u].pb(v);
		edge[v].pb(u);
	}
	dfs(1);
	tp[1] = 1;
	redfs(1);
	for (int K, m, r; q--; )
	{
		cin >> K >> m >> r;
		rep(i,0,K)
		{
			cin >> node[i];
			dis[node[i]] = dist(r, node[i]);
		}
		sort(node, node + K, cmp_dis);
		memset(dp, 0, (m+1) * sizeof(int));
		static bool mark[N];
		dp[1] = 1;
		upd_subtree(node[0], 1);
		mark[node[0]] = true;
		rep(i,1,K)
		{
			int u = node[i];
			int w = lca(u, r);
			int cnt = 0;
			cnt += query_path_to_root(u);
			cnt += query_path_to_root(r);
			cnt -= query_path_to_root(w) << 1;
			cnt += mark[w];
			per(j,1,m+1)
			{
				dp[j] = (ll)dp[j] * (j - cnt) % mod;
				mod_add(dp[j], dp[j-1]);
			}
			upd_subtree(u, 1);
			mark[u] = true;
		}
		rep(i,0,K)
		{
			upd_subtree(node[i], -1);
			mark[node[i]] = false;
		}
		int ans = 0;
		rep(i,1,m+1) mod_add(ans, dp[i]);
		cout << ans << endl;
	}
	return 0;
}


#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];
            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]);
        }
    }
    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[i - 1][v]];
    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 = 10010;
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[MX][PW];

void dfs(int v, int pr) {
    up[v][0] = pr;
    fi(1, PW) up[v][i] = up[up[v][i - 1]][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[a][i], b)) {
            a = up[a][i];
        }
    }
    return up[a][0];
}

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[c][0]) : 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;
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[MX][PW];

void dfs(int v, int pr) {
    up[v][0] = pr;
    fi(1, PW) up[v][i] = up[up[v][i - 1]][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[a][i], b)) {
            a = up[a][i];
        }
    }
    return up[a][0];
}

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[c][0]) : 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];
            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]);
        }
    }
    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[MX][PW];

void dfs(int v, int pr) {
    up[v][0] = pr;
    fi(1, PW) up[v][i] = up[up[v][i - 1]][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[a][i], b)) {
            a = up[a][i];
        }
    }
    return up[a][0];
}

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[c][0]) : 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[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;
}

void updlr(int l, int r, int x) {
    upd(l, x);
    upd(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]) {
        dp[0][0] = 1;
        int i = 1;

        auto len = [&](int a) {
            int result = 0;
            fx(bnd, bounds[a]) result += (bnd[1] - bnd[0] + 1) * bnd[2];
            return result;
        };
        sort(all(verts[id]), [&](int a, int b) {return len(a) > len(b);});

        fx(w, verts[id]) {
            int h = get(tin[w]);
            fx(bnd, bounds[w]) updlr(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;
        }
        for (int j = 0; j <= m[id]; ++j)
            ans[id] = add(ans[id], dp[i - 1][j]);

        fx(w, verts[id]) fx(bnd, bounds[w]) updlr(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';
}