#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
const int SQ = 318;
int dist[MAXN], marc[MAXN];
int vis[MAXN], in[MAXN];
vector<int> adj[MAXN];
pair<int, int> dp[MAXN][SQ];
int n, m, q;
void bfs(int s){
queue<int> q;
for(int i=1; i<=n; i++) marc[i] = 0;
q.push(s);
dist[s] = 0; marc[s] = 1;
while(!q.empty()){
int v = q.front();
q.pop();
for(auto u : adj[v]){
if(!marc[u]){
marc[u] = 1;
dist[u] = dist[v] + 1;
q.push(u);
}
}
}
}
void merge(int u, int v){
int l = 0, r = 0;
vector<pair<int, int>> cur;
for(int i=0; i<SQ; i++) vis[dp[u][i].first] = vis[dp[v][i].first] = 0;
while((int) cur.size() < SQ){
while(l < SQ && vis[dp[v][r].first]) r++;
while(r < SQ && vis[dp[u][l].first]) l++;
if(r < SQ && dp[v][r].second + 1 > dp[u][l].second){
cur.push_back({dp[v][r].first, dp[v][r].second + 1});
r++;
} else cur.push_back(dp[u][l++]);
if(cur.back().first > 0) vis[cur.back().first] = 1;
}
for(int i=0; i<SQ; i++) dp[u][i] = cur[i];
}
void pre_bfs(){
queue<int> q;
for(int i=1; i<=n; i++){
dp[i][0] = {i, 0};
for(int j=1; j<SQ; j++) dp[i][j] = {0, -1e9};
if(in[i] == 0) q.push(i);
}
while(!q.empty()){
int v = q.front();
q.pop();
for(auto u : adj[v]){
in[u] --;
merge(u, v);
if(in[u] == 0) q.push(u);
}
}
}
int main(){
cin.tie(0)->sync_with_stdio(0);
cin >> n >> m >> q;
while(m--){
int a, b; cin >> a >> b;
adj[a].push_back(b);
in[b] ++;
}
pre_bfs();
vector<int> vis, to_skip(n + 1, 0);
for(int i=0; i<q; i++){
int t, y; cin >> t >> y;
vis.resize(y);
for(int j=0; j<y; j++){
cin >> vis[j];
to_skip[vis[j]] = 1;
}
if(y < SQ){
int x = 0;
while(to_skip[dp[t][x].first]) x++;
cout << max(-1, dp[t][x].second) << "\n";
} else{
bfs(t);
int ans = 0;
for(int j=1; j<=n; j++) if(!to_skip[j]) ans = max(ans, dist[j]);
cout << ans << "\n";
}
for(int j=0; j<y; j++) to_skip[vis[j]] = 0;
}
return 0;
}