#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#define endl '\n'
using namespace std;
const int MAXN = 1e5 + 10;
const int MAXM = 2e5 + 10;
const int INF = 1e9 + 10;
const int SQRT = 1000;
struct Path
{
int from;
int len;
Path(){};
Path(int from, int len)
{
this->from = from;
this->len = len;
}
inline friend bool operator<(const Path& p1, const Path& p2)
{
return p1.len > p2.len;
}
};
int n, m, q;
vector < int > revadj[MAXN];
vector < Path > paths[MAXN];
int dp[MAXN];
bool banned[MAXN];
void read()
{
cin >> n >> m >> q;
for(int i = 1; i <= m; i++)
{
int u, v;
cin >> u >> v;
revadj[v].push_back(u);
}
}
void precomp()
{
for(int i = 1; i <= n; i++)
{
dp[i] = -1;
}
for(int u = 1; u <= n; u++)
{
vector < int > reachable;
paths[u].push_back(Path(u, 0));
for(int& v : revadj[u])
{
for(Path& p : paths[v])
{
if(dp[p.from] == -1)
{
reachable.push_back(p.from);
}
dp[p.from] = max(dp[p.from], p.len + 1);
}
}
for(int& r : reachable)
{
paths[u].push_back(Path(r, dp[r]));
}
sort(paths[u].begin(), paths[u].end());
while(paths[u].size() > SQRT)
{
paths[u].pop_back();
}
for(int& r : reachable)
{
dp[r] = -1;
}
}
}
void process_queries()
{
for(int i = 1; i <= q; i++)
{
int t, k;
cin >> t >> k;
vector < int > absent;
for(int j = 0; j < k; j++)
{
int s;
cin >> s;
if(s > t)
continue;
absent.push_back(s);
banned[s] = true;
}
k = absent.size();
if(k <= SQRT)
{
int ans = -1;
for(Path& p : paths[t])
{
if(!banned[p.from])
{
ans = p.len;
break;
}
}
cout << ans << endl;
}
else
{
for(int u = 1; u <= n; u++)
{
dp[u] = (banned[u] ? -INF : 0);
}
for(int u = 1; u <= t; u++)
{
for(int& v : revadj[u])
{
dp[u] = max(dp[u], dp[v] + 1);
}
}
cout << max(-1, dp[t]) << endl;
}
for(int& u : absent)
{
banned[u] = false;
}
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
read();
precomp();
process_queries();
return 0;
}