func_code_string: #include <bits/stdc++.h>   using namespace std;   long long n, k;   long long pr[300005], cr[300005];   long long nr[300005][2], fr[300005][2];   bool visit[300005], visit1[300005];   char str[300005];   vector<long long> vr[300005], br[300005];   void pre(), dfs(long long, long long);   long long uni(long long, long long), ccon(long long), ffind(long long);   int main() {     pre();     for (int i = 1; i < k + 1; i++)       if (!visit[i]) dfs(i, 0);     long long ans = 0;     for (int idx = 1; idx < n + 1; idx++) {       if (br[idx].size() == 1) {         long long v1 = br[idx][0];         ans -= ccon(v1);         if (str[idx] ==  0 ) {           fr[ffind(v1)][cr[v1]] = 1;         } else {           fr[ffind(v1)][!cr[v1]] = 1;         }         ans += ccon(v1);       } else if (br[idx].size() == 2) {         long long v1 = br[idx][0], v2 = br[idx][1];         if (ffind(v1) != ffind(v2)) {           ans -= ccon(v1) + ccon(v2);           long long p = uni(ffind(v1), ffind(v2));           ans += ccon(p);         }       }       cout << ans <<   n ;     }   }   long long ffind(long long idx) {     if (pr[idx] != idx) return pr[idx] = ffind(pr[idx]);     return idx;   }   long long uni(long long x, long long y) {     if (x == y) return x;     if (nr[x][0] + nr[x][1] < nr[y][0] + nr[y][1]) swap(x, y);     pr[y] = x;     nr[x][0] += nr[y][0];     nr[x][1] += nr[y][1];     fr[x][0] += fr[y][0];     fr[x][1] += fr[y][1];     return x;   }   long long ccon(long long idx) {     long long c = cr[idx];     long long p = ffind(idx);     if (fr[p][0]) return nr[p][0];     if (fr[p][1]) return nr[p][1];     return min(nr[p][0], nr[p][1]);   }   void pre() {     cin >> n >> k;     cin >> str + 1;     for (int i = 1; i < k + 1; i++) {       long long s;       cin >> s;       for (int j = 0; j < s; j++) {         long long x;         cin >> x;         vr[i].push_back(x);         br[x].push_back(i);       }     }   }   void dfs(long long idx, long long t) {     if (visit[idx]) return;     visit[idx] = true;     nr[idx][t] = 1;     cr[idx] = t;     pr[idx] = idx;     for (int i = 0; i < vr[idx].size(); i++) {       long long v = vr[idx][i];       for (int j = 0; j < br[v].size(); j++) {         long long node = br[v][j];         dfs(node, str[v] ==  1  ? t : !t);       }     }   }   