There are n lamps on a line, numbered from 1 to n. Each one has an initial state off (0) or on (1).

You're given k subsets A_1, …, A_k of \{1, 2, ..., n\}, such that the intersection of any three subsets is empty. In other words, for all 1 ≤ i_1 < i_2 < i_3 ≤ k, A_{i_1} ∩ A_{i_2} ∩ A_{i_3} = ∅.

In one operation, you can choose one of these k subsets and switch the state of all lamps in it. It is guaranteed that, with the given subsets, it's possible to make all lamps be simultaneously on using this type of operation.

Let m_i be the minimum number of operations you have to do in order to make the i first lamps be simultaneously on. Note that there is no condition upon the state of other lamps (between i+1 and n), they can be either off or on.

You have to compute m_i for all 1 ≤ i ≤ n.

Input

The first line contains two integers n and k (1 ≤ n, k ≤ 3 ⋅ 10^5).

The second line contains a binary string of length n, representing the initial state of each lamp (the lamp i is off if s_i = 0, on if s_i = 1).

The description of each one of the k subsets follows, in the following format:

The first line of the description contains a single integer c (1 ≤ c ≤ n) — the number of elements in the subset.

The second line of the description contains c distinct integers x_1, …, x_c (1 ≤ x_i ≤ n) — the elements of the subset.

It is guaranteed that: 

  * The intersection of any three subsets is empty; 
  * It's possible to make all lamps be simultaneously on using some operations. 

Output

You must output n lines. The i-th line should contain a single integer m_i — the minimum number of operations required to make the lamps 1 to i be simultaneously on.

Examples

Input


7 3
0011100
3
1 4 6
3
3 4 7
2
2 3


Output


1
2
3
3
3
3
3


Input


8 6
00110011
3
1 3 8
5
1 2 5 6 7
2
6 8
2
3 5
2
4 7
1
2


Output


1
1
1
1
1
1
4
4


Input


5 3
00011
3
1 2 3
1
4
3
3 4 5


Output


1
1
1
1
1


Input


19 5
1001001001100000110
2
2 3
2
5 6
2
8 9
5
12 13 14 15 16
1
19


Output


0
1
1
1
2
2
2
3
3
3
3
4
4
4
4
4
4
4
5

Note

In the first example: 

  * For i = 1, we can just apply one operation on A_1, the final states will be 1010110; 
  * For i = 2, we can apply operations on A_1 and A_3, the final states will be 1100110; 
  * For i ≥ 3, we can apply operations on A_1, A_2 and A_3, the final states will be 1111111. 



In the second example: 

  * For i ≤ 6, we can just apply one operation on A_2, the final states will be 11111101; 
  * For i ≥ 7, we can apply operations on A_1, A_3, A_4, A_6, the final states will be 11111111. 
#include <bits/stdc++.h>
using namespace std;
template <class t>
inline t read(t &x) {
  x = 0;
  char c = getchar();
  bool f = 0;
  while (!isdigit(c)) f |= c == '-', c = getchar();
  while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  if (f) x = -x;
  return x;
}
template <class t>
inline void write(t x) {
  if (x < 0) {
    putchar('-'), write(-x);
  } else {
    if (x > 9) write(x / 10);
    putchar('0' + x % 10);
  }
}
const long long N = 3e5 + 5;
long long n, k, SsEeTt[N][3], f[N << 1], sz[N << 1], s[N], ans, oo;
inline long long min(const long long &x, const long long &y) {
  return x < y ? x : y;
}
inline long long getf(const long long &x) {
  return f[x] == x ? x : f[x] = getf(f[x]);
}
signed main() {
  read(n);
  oo = read(k);
  for (long long i = 1; i <= n; i++) scanf("%1d", &s[i]);
  for (long long i = 1, n, x; i <= k; i++) {
    read(n);
    while (n--) {
      read(x);
      if (!SsEeTt[x][1])
        SsEeTt[x][1] = i;
      else
        SsEeTt[x][2] = i;
    }
  }
  for (long long i = 1; i <= k; i++) {
    f[i * 2 - 1] = i * 2 - 1;
    f[i << 1] = i << 1;
    sz[i << 1] = 1;
  }
  for (long long i = 1, fx, fy, gx, gy; i <= n; i++) {
    if (SsEeTt[i][2]) {
      if (!s[i]) {
        fx = getf(SsEeTt[i][1] * 2 - 1), fy = getf(SsEeTt[i][2] << 1);
        if (fx == fy) {
          write(ans);
          puts("");
          continue;
        }
        gx = getf(SsEeTt[i][1] << 1), gy = getf(SsEeTt[i][2] * 2 - 1);
      } else {
        fx = getf(SsEeTt[i][1] * 2 - 1), fy = getf(SsEeTt[i][2] * 2 - 1);
        if (fx == fy) {
          write(ans);
          puts("");
          continue;
        }
        gx = getf(SsEeTt[i][1] << 1), gy = getf(SsEeTt[i][2] << 1);
      }
      ans -= min(sz[fx], sz[gx]) + min(sz[fy], sz[gy]);
      f[fx] = fy;
      f[gx] = gy;
      sz[fy] += sz[fx];
      sz[gy] += sz[gx];
      ans += min(sz[fy], sz[gy]);
    } else if (SsEeTt[i][1]) {
      long long fx = getf(SsEeTt[i][1] * 2 - 1), fy = getf(SsEeTt[i][1] * 2);
      ans -= min(sz[fx], sz[fy]);
      if (!s[i])
        sz[fx] += oo;
      else
        sz[fy] += oo;
      ans += min(sz[fx], sz[fy]);
    }
    write(ans);
    puts("");
  }
}
