#include #include #include #include using namespace std; int uf[100000]; int mx; int root(int i) { return (uf[i] < 0 ? i : uf[i] = root(uf[i])); } void merge(int i, int j) { if((i = root(i)) == (j = root(j))) return ; if(uf[i] < uf[j]) swap(i, j); mx -= 1; uf[j] += uf[i]; uf[i] = j; return ; } int A[100000]; int D[100000]; int main() { ios::sync_with_stdio(false); cin.tie(NULL); memset(uf, -1, sizeof uf); int n, e, p; cin >> n >> e >> p; vector > vex(n); int u, v; while(e--) { cin >> u >> v; u -= 1; v -= 1; vex[u].push_back(v); vex[v].push_back(u); } while(p--) { int m; cin >> m; mx = m; for(int i = 0; i < m; ++i) { cin >> A[i]; A[i] -= 1; D[A[i]] = 1; for(int r : vex[A[i]]) if(D[r]) merge(A[i], r); } cout << mx << '\n'; for(int i = 0; i < m; ++i) D[A[i]] += (uf[A[i]] = -1); } return 0; }