#include <bits/stdc++.h>
using namespace std;
int n, k, a[600005], fa[600005], val[600005], ans;
string s;
vector<int> v[600005];
int get(int x) {
  if (fa[x] != x) fa[x] = get(fa[x]);
  return fa[x];
}
void merge(int x, int y) {
  x = get(x);
  y = get(y);
  if (x != y) {
    fa[x] = y;
    val[y] += val[x];
  }
}
int va(int x) { return min(val[get(x)], val[get(x + k)]); }
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> k >> s;
  s = "0" + s;
  for (int i = 1; i <= k; i++) {
    int c, x;
    cin >> c;
    while (c--) {
      cin >> x;
      v[x].push_back(i);
    }
  }
  for (int i = 1; i <= (k * 2); i++) {
    fa[i] = i;
    val[i] = i > k;
  }
  fa[k * 2 + 1] = k * 2 + 1;
  val[k * 2 + 1] = 1000000000;
  for (int i = 1; i <= n; i++) {
    if (v[i].size() == 1) {
      int x = v[i][0] + (s[i] == '1') * k;
      ans -= va(v[i][0]);
      merge(x, k * 2 + 1);
      ans += va(v[i][0]);
    } else if (v[i].size() == 2) {
      int x = v[i][0], y = v[i][1];
      if (s[i] == '0') {
        if (get(x) != get(y + k)) {
          ans -= va(x) + va(y);
          merge(x, y + k);
          merge(x + k, y);
          ans += va(x);
        }
      } else {
        if (get(x) != get(y)) {
          ans -= va(x) + va(y);
          merge(x, y);
          merge(x + k, y + k);
          ans += va(x);
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
