#ifdef LOCAL
#include "stdafx.h"
#else
#include <bits/stdc++.h>
#define IL inline
#define LL long long
#define eb emplace_back
#define L(i, j, k) for (int i = (j); i <= (k); ++i)
#define R(i, j, k) for (int i = (j); i >= (k); --i)
using namespace std;
using vi = vector<int>;
#endif
#define mc(f, g) memcpy(f, g, sizeof(f))
#define me(f, x) memset(f, x, sizeof(f))
constexpr int N = 1e5 + 9;
constexpr int M = 59;
int n, m, Q;
vi g[N];
int deg[N];
vi to[N];
int dom[N], d[N], fa[N][20];
int lca (int x, int y) {
if (d[x] < d[y]) {
swap(x, y);
}
R (i, 19, 0) {
if (d[fa[x][i]] >= d[y]) {
x = fa[x][i];
}
}
if (x == y) {
return x;
}
R (i, 19, 0) {
if (fa[x][i] ^ fa[y][i]) {
x = fa[x][i];
y = fa[y][i];
}
}
return dom[x];
}
void get_dom () {
queue<int> q;
L (i, 1, n) {
if (!deg[i]) {
q.push(i);
}
}
while (!q.empty()) {
int u = q.front();
to[dom[u]].eb(u);
d[u] = d[dom[u]] + 1;
fa[u][0] = dom[u];
L (i, 1, 19) {
fa[u][i] = fa[fa[u][i - 1]][i - 1];
}
q.pop();
for (int v : g[u]) {
if (!dom[v]) {
dom[v] = u;
} else {
dom[v] = lca(dom[v], u);
}
if (!--deg[v]) {
q.push(v);
}
}
}
}
vi e[N];
int pt[N];
bitset<N> S[M];
bitset<M> V[N];
int L[N], R[N], dfc;
void dfs1 (int u) {
L[u] = ++dfc;
bool fl = false;
for (int v : g[u]) {
if (!L[v]) {
dfs1(v);
e[u].eb(v);
} else {
fl = true;
}
}
R[u] = dfc;
if (fl) {
pt[m++] = u;
}
}
void dfs2 (int u) {
for (int v : e[u]) {
dfs2(v);
V[u] |= V[v];
}
}
void get_S () {
m = 0;
dfs1(1);
L (i, 0, m - 1) {
queue<int> q;
q.push(pt[i]);
S[i].set(pt[i]);
while (!q.empty()) {
int u = q.front();
q.pop();
for (int v : g[u]) {
if (!S[i].test(v)) {
q.push(v);
S[i].set(v);
}
}
}
}
L (i, 0, m - 1) {
V[pt[i]].set(i);
}
dfs2(1);
}
int dfn[N], son[N], top[N], h[N];
void dfs3 (int u) {
h[u] = d[u];
dfn[u] = ++dfc;
for (int v : to[u]) {
dfs3(v);
if (h[v] > h[u]) {
son[u] = v;
h[u] = h[v];
}
}
}
vi down[N], up[N];
void dfs4 (int u, int t) {
top[u] = t;
if (u == t) {
int sz = h[u] - d[u] + 1;
up[u].resize(sz);
down[u].resize(sz);
up[u][0] = u;
down[u][0] = u;
L (i, 1, sz - 1) {
up[u][i] = dom[up[u][i - 1]];
down[u][i] = son[down[u][i - 1]];
}
}
if (son[u]) {
dfs4(son[u], t);
}
for (int v : to[u]) {
if (v ^ son[u]) {
dfs4(v, v);
}
}
}
int kth (int x, int k) {
if (k == 0) {
return x;
}
int bit = 31 - __builtin_clz(k);
k ^= 1 << bit;
x = fa[x][bit];
k -= d[x] - d[top[x]];
x = top[x];
return k < 0 ? down[x][-k] : up[x][k];
}
void init () {
get_dom();
get_S();
dfc = 0;
dfs3(1);
dfs4(1, 1);
}
bool can_reach (int x, int y) {
if (L[x] <= L[y] && L[y] <= R[x]) {
return true;
}
for (int i = V[x]._Find_first(); i < M; i = V[x]._Find_next(i)) {
if (S[i].test(y)) {
return true;
}
}
return false;
}
int p[N], tot, k;
bool tour[N];
int vt[N << 1], par[N];
vi ch[N];
LL dp[N][5], tdp[5];
void dfs (int u) {
vector<int> c;
c.reserve(k);
for (int x = u; par[x]; x = par[x]) {
if (c.size() + ch[par[x]].size() - 1 > k) {
break;
}
for (int y : ch[par[x]]) {
if (y != x) {
c.eb(y);
}
}
}
int len = d[u] - d[par[u]];
int l = 0, r = len - 1;
auto is_ok = [&] (int x) {
for (int y : c) {
if (can_reach(x, y)) {
return false;
}
}
return true;
};
while (l < r) {
int m = (l + r + 1) >> 1;
is_ok(kth(u, m)) ? l = m : r = m - 1;
}
int val = is_ok(kth(u, l)) ? l + 1 : 0;
if (!tour[u]) {
dp[u][0] = 1;
for (int v : ch[u]) {
dfs(v);
me(tdp, 0);
L (i, 0, k) {
L (j, 1, k - i) {
tdp[i + j] += dp[u][i] * dp[v][j];
}
}
mc(dp[u], tdp);
}
}
dp[u][1] += val;
}
int main () {
FIO("1");
ios::sync_with_stdio(0), cin.tie(0);
cin >> n >> m >> Q;
L (i, 1, m) {
int u, v;
cin >> u >> v;
g[u].eb(v), ++deg[v];
}
init();
while (Q--) {
cin >> k >> tot;
L (i, 1, tot) {
cin >> p[i];
tour[p[i]] = true;
}
sort(p + 1, p + tot + 1, [] (int x, int y) {
return dfn[x] < dfn[y];
});
L (i, 1, tot) {
vt[i] = p[i];
}
L (i, 1, tot - 1) {
vt[tot + i] = lca(p[i], p[i + 1]);
}
int sz = (tot << 1) - 1;
sort(vt + 1, vt + sz + 1, [] (int x, int y) {
return dfn[x] < dfn[y];
});
sz = unique(vt + 1, vt + sz + 1) - vt - 1;
L (i, 2, sz) {
int l = lca(vt[i - 1], vt[i]);
par[vt[i]] = l;
ch[l].eb(vt[i]);
}
dfs(vt[1]);
cout << dp[vt[1]][k] << '\n';
L (i, 1, sz) {
par[vt[i]] = 0;
ch[vt[i]].clear();
me(dp[vt[i]], 0);
}
L (i, 1, tot) {
tour[p[i]] = false;
}
}
}
// I love WHQ!