#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300300;
int n, k, uf[2 * MAXN], cnt[2 * MAXN], ans;
vector<int> f[MAXN];
char s[MAXN];
int find(int x) { return (uf[x] != -1 ? uf[x] = find(uf[x]) : x); }
void join(int x, int y) {
  if ((x = find(x)) == (y = find(y))) return;
  cnt[x] += cnt[y];
  uf[y] = x;
}
int main() {
  scanf("%d %d %s", &n, &k, s + 1);
  memset(uf, -1, sizeof uf);
  cnt[1] = MAXN;
  for (int i = 1, c; i <= k; ++i) {
    cnt[2 * i + 1] = 1;
    scanf("%d", &c);
    for (int j = 1, x; j <= c; ++j) scanf("%d", &x), f[x].push_back(i);
  }
  for (int i = 1; i <= n; ++i) {
    if (!f[i].empty()) {
      if (f[i].size() == 1) f[i].push_back(0);
      bool b = s[i] == '0';
      if (find(2 * f[i][0]) != find(2 * f[i][1] ^ b)) {
        ans -= min(cnt[find(2 * f[i][0])], cnt[find(2 * f[i][0] + 1)]);
        ans -= min(cnt[find(2 * f[i][1])], cnt[find(2 * f[i][1] + 1)]);
        join(2 * f[i][0], 2 * f[i][1] ^ b),
            join(2 * f[i][0] + 1, 2 * f[i][1] + 1 ^ b);
        ans += min(cnt[find(2 * f[i][0])], cnt[find(2 * f[i][0] + 1)]);
      }
    }
    printf("%d\n", ans);
  }
}
