import numpy as np

N,M = list(map(int, input().split()))

S = []

for i in range(M):

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

    T = [0]*N

    for j in s:

        T[j-1]=1

    S.append(T)

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

ans =0

for x in range(2**N):

    y = format(x,"0{}b".format(N))

    z = list(map(int,y))

    if all(np.dot(den,z)%2==P[nmb] for nmb,den in enumerate(S)):

        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()))

count = 0

for i in range(1<<N):

    for m in range(M):

        switch=0

        for j in range(N):

            if (i>>j)&1 and j+1 in s[m]:

                switch += 1

        if switch%2!= p[m]:

            break

    else:

        count += 1

print(count)
import numpy as np

N, M = list(map(int, input().split()))
S = []
for i in range(M):
    k, *s = list(map(int, input().split()))
    T = [0] * N
    for j in s:
        T[j - 1] = 1
    S.append(T)
P = list(map(int, input().split()))
ans = 0
for x in range(2**N):
    y = format(x, "0{}b".format(N))
    z = list(map(int, y))
    if all(np.dot(den, z) % 2 == P[nmb] for nmb, den in enumerate(S)):
        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()))
count = 0
for i in range(1 << N):
    for m in range(M):
        switch = 0
        for j in range(N):
            if (i >> j) & 1 and j + 1 in s[m]:
                switch += 1
        if switch % 2 != p[m]:
            break
    else:
        count += 1
print(count)

-import numpy as np - -S = [] -for i in range(M): -    k, *s = list(map(int, input().split())) -    T = [0] * N -    for j in s: -        T[j - 1] = 1 -    S.append(T) -P = list(map(int, input().split())) -ans = 0 -for x in range(2**N): -    y = format(x, "0{}b".format(N)) -    z = list(map(int, y)) -    if all(np.dot(den, z) % 2 == P[nmb] for nmb, den in enumerate(S)): -        ans += 1 -print(ans) +s = [list(map(int, input().split()))[1:] for _ in range(M)] +p = list(map(int, input().split())) +count = 0 +for i in range(1 << N): +    for m in range(M): +        switch = 0 +        for j in range(N): +            if (i >> j) & 1 and j + 1 in s[m]: +                switch += 1 +        if switch % 2 != p[m]: +            break +    else: +        count += 1 +print(count)