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, \ldots, A_k$ of $\{1, 2, \dots, n\}$, such that the intersection of any three subsets is empty. In other words, for all $1 \le i_1 < i_2 < i_3 \le k$, $A_{i_1} \cap A_{i_2} \cap A_{i_3} = \varnothing$.

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 \le i \le n$.


-----Input-----

The first line contains two integers $n$ and $k$ ($1 \le n, k \le 3 \cdot 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 \le c \le n$)  — the number of elements in the subset.

The second line of the description contains $c$ distinct integers $x_1, \ldots, x_c$ ($1 \le x_i \le 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 \ge 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 \le 6$, we can just apply one operation on $A_2$, the final states will be $11111101$;  For $i \ge 7$, we can apply operations on $A_1, A_3, A_4, A_6$, the final states will be $11111111$.

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = "import sys\nreadline = sys.stdin.readline\nclass UF():\n    def __init__(self, num):\n        self.par = [-1]*num\n        self.weight = [0]*num\n    def find(self, x):\n        if self.par[x] < 0:\n            return x\n        else:\n            stack = []\n            while self.par[x] >= 0:\n                stack.append(x)\n                x = self.par[x]\n            for xi in stack:\n                self.par[xi] = x\n            return x\n    \n    def union(self, x, y):\n        rx = self.find(x)\n        ry = self.find(y)\n        if rx != ry:\n            if self.par[rx] > self.par[ry]:\n                rx, ry = ry, rx\n            self.par[rx] += self.par[ry]\n            self.par[ry] = rx\n            self.weight[rx] += self.weight[ry]\n        return rx\n\nN, K = list(map(int, readline().split()))\nS = list(map(int, readline().strip()))\n\nA = [[] for _ in range(N)]\n\nfor k in range(K):\n    BL = int(readline())\n    B = list(map(int, readline().split()))\n    for b in B:\n        A[b-1].append(k)\n\ncnt = 0\nT = UF(2*K)\nused = set()\nAns = [None]*N\ninf = 10**9+7\nfor i in range(N):\n    if not len(A[i]):\n        Ans[i] = cnt\n        continue\n    kk = 0\n    if len(A[i]) == 2:    \n        x, y = A[i]\n        if S[i]:\n            rx = T.find(x)\n            ry = T.find(y)\n            if rx != ry:\n                rx2 = T.find(x+K)\n                ry2 = T.find(y+K)\n                sp = min(T.weight[rx], T.weight[rx2]) + min(T.weight[ry], T.weight[ry2])\n                if x not in used:\n                    used.add(x)\n                    T.weight[rx] += 1\n                if y not in used:\n                    used.add(y)\n                    T.weight[ry] += 1\n                rz = T.union(rx, ry)\n                rz2 = T.union(rx2, ry2)\n                sf = min(T.weight[rz], T.weight[rz2])\n                kk = sf - sp\n        else:\n            rx = T.find(x)\n            ry2 = T.find(y+K)\n            sp = 0\n            if rx != ry2:\n                ry = T.find(y)\n                rx2 = T.find(x+K)\n                sp = min(T.weight[rx], T.weight[rx2]) + min(T.weight[ry], T.weight[ry2])\n                if x not in used:\n                    used.add(x)\n                    T.weight[rx] += 1\n                if y not in used:\n                    used.add(y)\n                    T.weight[ry] += 1\n                rz = T.union(rx, ry2)\n                rz2 = T.union(rx2, ry)\n                sf = min(T.weight[rz], T.weight[rz2])\n                kk = sf - sp\n    else:\n        if S[i]:\n            x = A[i][0]\n            rx = T.find(x)\n            rx2 = T.find(x+K)\n            sp = min(T.weight[rx], T.weight[rx2])\n            T.weight[rx] += inf\n            sf = min(T.weight[rx], T.weight[rx2])\n            kk = sf - sp\n        else:\n            x = A[i][0]\n            rx = T.find(x)\n            rx2 = T.find(x+K)\n            sp = min(T.weight[rx], T.weight[rx2])\n            T.weight[rx2] += inf\n            if x not in used:\n                used.add(x)\n                T.weight[rx] += 1\n            sf = min(T.weight[rx], T.weight[rx2])\n            kk = sf-sp\n    Ans[i] = cnt + kk\n    cnt = Ans[i]            \nprint('\\n'.join(map(str, Ans)))\n            \n"
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 18935