#include<bits/stdc++.h>
using namespace std;
vector<int> pol[1000005];
int lider[1000005];
vector<int> v;
bool odw[1000005];
bool skurwiel[1000005];
set<int> s;
int f(int a)
{
    if(lider[a]!=a)
        lider[a]=f(lider[a]);
    return lider[a];
}
void u(int a,int b)
{
    lider[f(a)]=f(b);
}
void pre(int a)
{
    for(int x=1;x<=a;x++)
        lider[x]=x;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a,b,c,d,t;
    cin>>a>>b>>t;
    pre(a);
    while(b--)
    {
        cin>>c>>d;
        pol[c].push_back(d);
        pol[d].push_back(c);
    }
    int pierw=sqrt(a);
    for(int x=1;x<=a;x++)
        if(pol[x].size()>pierw)
            skurwiel[x]=true;
    for(int x=1;x<=a;x++)
        if(skurwiel[x]==true)
        {
            for(auto y:pol[x])
                if(skurwiel[y]==true)
                    v.push_back(y);
            pol[x]=v;
            v.resize(0);
        }
    while(t--)
    {
        cin>>c;
        for(int x=0;x<c;x++)
        {
            cin>>d;
            v.push_back(d);
            odw[d]=true;
        }
        for(auto x:v)
            for(auto y:pol[x])
                if(odw[y]==true)
                    u(x,y);
        for(auto x:v)
            s.insert(f(x));
        cout<<s.size()<<'\n';
        s.clear();
        for(auto x:v)
        {
            odw[x]=false;
            lider[x]=x;
        }
        v.resize(0);
    }
    return 0;
}

