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

kss = [list(map(int, input().split())) for _ in range(M)]

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



answer = 0

for i in range(1 << N):

    for (_, *ss), p in zip(kss, ps):

        okay = True

        if sum([(i >> s-1) & 1 for s in ss]) % 2 != p:

            okay = False

            break

    if okay:

        answer += 1



print(answer)

from itertools import product



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

kss = [list(map(int, input().split())) for _ in range(M)]

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



answer = 0

for switches in product(list(range(2)), repeat=N):

    for (_, *ss), p in zip(kss, ps):

        okay = True

        if sum([switches[s-1] for s in ss]) % 2 != p:

            okay = False

            break

    if okay:

        answer += 1



print(answer)

N, M = list(map(int, input().split()))
kss = [list(map(int, input().split())) for _ in range(M)]
ps = list(map(int, input().split()))
answer = 0
for i in range(1 << N):
    for (_, *ss), p in zip(kss, ps):
        okay = True
        if sum([(i >> s - 1) & 1 for s in ss]) % 2 != p:
            okay = False
            break
    if okay:
        answer += 1
print(answer)

from itertools import product

N, M = list(map(int, input().split()))
kss = [list(map(int, input().split())) for _ in range(M)]
ps = list(map(int, input().split()))
answer = 0
for switches in product(list(range(2)), repeat=N):
    for (_, *ss), p in zip(kss, ps):
        okay = True
        if sum([switches[s - 1] for s in ss]) % 2 != p:
            okay = False
            break
    if okay:
        answer += 1
print(answer)

+from itertools import product + -for i in range(1 << N): +for switches in product(list(range(2)), repeat=N): -        if sum([(i >> s - 1) & 1 for s in ss]) % 2 != p: +        if sum([switches[s - 1] for s in ss]) % 2 != p: