#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5;
const int inf = 1e9;
char s[maxn + 5];
vector<int> g[maxn + 5];
int f[maxn + 5], v[maxn + 5];
int ans[maxn + 5][2];
int n, m;
int res;
int find(int x) {
  if (f[x] == x) return x;
  int father = find(f[x]);
  v[x] ^= v[f[x]];
  return f[x] = father;
}
void merge(int x, int y, int value) {
  int fx = find(x), fy = find(y);
  if (fx == fy) return;
  f[fy] = fx;
  v[fy] = v[x] ^ v[y] ^ value;
  res -= min(ans[fx][0], ans[fx][1]);
  res -= min(ans[fy][0], ans[fy][1]);
  ans[fx][0] += ans[fy][0 ^ v[fy]];
  ans[fx][1] += ans[fy][1 ^ v[fy]];
  ans[fx][0] = min(ans[fx][0], inf);
  ans[fx][1] = min(ans[fx][1], inf);
  res += min(ans[fx][0], ans[fx][1]);
}
int main() {
  cin >> n >> m;
  scanf("%s", s + 1);
  for (int i = 1; i <= m; ++i) {
    int num, x;
    scanf("%d", &num);
    while (num--) {
      scanf("%d", &x);
      g[x].push_back(i);
    }
  }
  for (int i = 1; i <= n; ++i)
    if (g[i].size() == 1) g[i].push_back(0);
  for (int i = 1; i <= m; ++i) f[i] = i, v[i] = 0, ans[i][0] = 0, ans[i][1] = 1;
  f[0] = 0, v[0] = 0, ans[0][0] = 0, ans[0][1] = inf;
  for (int i = 1; i <= n; ++i) {
    if (!g[i].empty()) {
      merge(g[i][0], g[i][1], 49 - s[i]);
    }
    printf("%d\n", res);
  }
  return 0;
}
