n,m=list(map(int,input().split()))

S=[list(map(int,input().split()))[1:] for _ in range(m)]

P=list(map(int,input().split()))



cnt=0

for i in range(2**n):

    Q=0

    switch=set([i+1 for i,j in enumerate(format(i,"b").zfill(n)[::-1]) if j == '1'])

    for k,j in enumerate(S):

        if len(switch&set(j))%2==P[k]:

            Q+=1

    if Q==m:

        cnt+=1



print(cnt)
import sys



n, m = list(map(int, input().split()))

swi = []

for _ in range(m):

    k, *sss = list(map(int, input().split()))

    t = 0

    for s in sss:

        t += 1 << (s - 1)

    swi.append(t)

ppp = list(map(int, input().split()))



ans = 0

for i in range(1 << n):

    for s, p in zip(swi, ppp):

        t = i & s

        c = bin(t).count('1') % 2

        if c != p:

            break

    else:

        ans += 1

print(ans)
n, m = list(map(int, input().split()))
S = [list(map(int, input().split()))[1:] for _ in range(m)]
P = list(map(int, input().split()))
cnt = 0
for i in range(2**n):
    Q = 0
    switch = set(
        [i + 1 for i, j in enumerate(format(i, "b").zfill(n)[::-1]) if j == "1"]
    )
    for k, j in enumerate(S):
        if len(switch & set(j)) % 2 == P[k]:
            Q += 1
    if Q == m:
        cnt += 1
print(cnt)

import sys

n, m = list(map(int, input().split()))
swi = []
for _ in range(m):
    k, *sss = list(map(int, input().split()))
    t = 0
    for s in sss:
        t += 1 << (s - 1)
    swi.append(t)
ppp = list(map(int, input().split()))
ans = 0
for i in range(1 << n):
    for s, p in zip(swi, ppp):
        t = i & s
        c = bin(t).count("1") % 2
        if c != p:
            break
    else:
        ans += 1
print(ans)

+import sys + -S = [list(map(int, input().split()))[1:] for _ in range(m)] -P = list(map(int, input().split())) -cnt = 0 -for i in range(2**n): -    Q = 0 -    switch = set( -        [i + 1 for i, j in enumerate(format(i, "b").zfill(n)[::-1]) if j == "1"] -    ) -    for k, j in enumerate(S): -        if len(switch & set(j)) % 2 == P[k]: -            Q += 1 -    if Q == m: -        cnt += 1 -print(cnt) +swi = [] +for _ in range(m): +    k, *sss = list(map(int, input().split())) +    t = 0 +    for s in sss: +        t += 1 << (s - 1) +    swi.append(t) +ppp = list(map(int, input().split())) +ans = 0 +for i in range(1 << n): +    for s, p in zip(swi, ppp): +        t = i & s +        c = bin(t).count("1") % 2 +        if c != p: +            break +    else: +        ans += 1 +print(ans)