#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
pair<int, int> dsu[2 * N];
string s;
int g[N][2], n, k, x, c, ans = 0, flag[2 * N];
int find(int x) {
  if (dsu[x].first == x) return x;
  return dsu[x].first = find(dsu[x].first);
}
void merge(int x, int y) {
  int a = find(x);
  int b = find(y);
  if (a == b) return;
  dsu[b].second += dsu[a].second;
  dsu[a].first = dsu[b].first;
  flag[b] |= flag[a];
}
int calc(int x) {
  int a = find(x);
  int b = find(x + k);
  if (flag[a]) return dsu[a].second;
  if (flag[b]) return dsu[b].second;
  return min(dsu[a].second, dsu[b].second);
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k >> s;
  for (int i = 1; i <= k; i++) {
    cin >> c;
    while (c--) {
      cin >> x;
      if (g[x][0] == 0)
        g[x][0] = i;
      else
        g[x][1] = i;
    }
  }
  for (int i = 1; i <= k + k; i++) dsu[i] = {i, i <= k};
  for (int i = 1; i <= n; i++) {
    if (g[i][0] > 0 && g[i][1] > 0) {
      if (s[i - 1] == '1' && find(g[i][0]) != find(g[i][1])) {
        ans -= calc(g[i][0]) + calc(g[i][1]);
        merge(g[i][0], g[i][1]);
        merge(g[i][0] + k, g[i][1] + k);
        ans += calc(g[i][0]);
      } else if (s[i - 1] == '0' && find(g[i][0]) != find(g[i][1] + k)) {
        ans -= calc(g[i][0]) + calc(g[i][1]);
        merge(g[i][0] + k, g[i][1]);
        merge(g[i][0], g[i][1] + k);
        ans += calc(g[i][0]);
      }
    } else if (g[i][0] > 0) {
      ans -= calc(g[i][0]);
      if (s[i - 1] == '1')
        flag[find(g[i][0] + k)] = 1;
      else
        flag[find(g[i][0])] = 1;
      ans += calc(g[i][0]);
    }
    cout << ans << '\n';
  }
}
