#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 3e5 + 5;
char s[N];
int n, k, l[N][2];
int fa[N * 2], sz[N * 2];
int getfa(int x) {
  if (x == fa[x]) return x;
  return fa[x] = getfa(fa[x]);
}
int calc(int x) {
  int y = (x <= k) ? x + k : x - k;
  x = getfa(x), y = getfa(y);
  if (x == 0 || y == 0) return sz[x + y];
  return min(sz[x], sz[y]);
}
void merge(int x, int y) {
  x = getfa(x), y = getfa(y);
  if (y == 0) {
    swap(x, y);
  }
  fa[y] = x;
  if (x != 0) {
    sz[x] += sz[y];
  }
}
int main() {
  scanf("%d%d%s", &n, &k, s + 1);
  for (int i = 1; i <= k; i++) {
    fa[i] = i;
    fa[i + k] = i + k;
    sz[i + k] = 1;
  }
  for (int i = 1, cnt; i <= k; i++) {
    scanf("%d", &cnt);
    for (int j = 1, x; j <= cnt; j++) {
      scanf("%d", &x);
      if (!l[x][0]) {
        l[x][0] = i;
      } else {
        l[x][1] = i;
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (l[i][1] == 0) {
      int x = l[i][0];
      if (x) {
        ans -= calc(x);
        if (s[i] == '1') {
          fa[getfa(x + k)] = 0;
        } else {
          fa[getfa(x)] = 0;
        }
        ans += calc(x);
      }
    } else {
      int x = l[i][0], y = l[i][1];
      if (s[i] == '1') {
        if (getfa(x) != getfa(y)) {
          ans -= calc(x);
          ans -= calc(y);
          merge(x, y);
          merge(x + k, y + k);
          ans += calc(x);
        }
      } else {
        if (getfa(x + k) != getfa(y)) {
          ans -= calc(x);
          ans -= calc(y);
          merge(x + k, y);
          merge(x, y + k);
          ans += calc(x);
        }
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
