from itertools import product

n, m = map(int, input().split())
ks = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))

ans = 0
for bit in product([0, 1], repeat=n):
    for ksi, pi in zip(ks, p):
        cnt = sum(bit[sij - 1] for sij in ksi[1:])
        if cnt % 2 != pi:
            break
    else:
        ans += 1
print(ans) from itertools import product n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m list(map(int, input().split())) for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split ks = [list(map(int, input().split())) for _ in range(m)] ks [list(map(int, input().split())) for _ in range(m)] p = list(map(int, input().split())) p list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split ans = 0 ans 0 for bit in product([0, 1], repeat=n):
    for ksi, pi in zip(ks, p):
        cnt = sum(bit[sij - 1] for sij in ksi[1:])
        if cnt % 2 != pi:
            break
    else:
        ans += 1 bit product([0, 1], repeat=n) product [0, 1] 0 1 repeat=n repeat n for ksi, pi in zip(ks, p):
        cnt = sum(bit[sij - 1] for sij in ksi[1:])
        if cnt % 2 != pi:
            break
    else:
        ans += 1 ksi pi zip(ks, p) zip ks p cnt = sum(bit[sij - 1] for sij in ksi[1:]) cnt sum(bit[sij - 1] for sij in ksi[1:]) sum bit[sij - 1] bit sij - 1 sij 1 if cnt % 2 != pi:
            break
     cnt % 2 != pi cnt % 2 cnt 2 pi break ans += 1 ans 1 print(ans) print ans ans += 1 1 ans ks = [list(map(int, input().split())) for _ in range(m)] [list(map(int, input().split())) for _ in range(m)] ks m = map(int, input().split()) map(int, input().split()) m ans = 0 0 ans n, m = map(int, input().split()) map(int, input().split()) n p = list(map(int, input().split())) list(map(int, input().split())) p cnt = sum(bit[sij - 1] for sij in ksi[1:]) sum(bit[sij - 1] for sij in ksi[1:]) cnt
from itertools import product

n, m = map(int, input().split())
ks = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))

ans = 0
for bit in product([0, 1], repeat=n):
    for ksi, pi in zip(ks, p):
        cnt = sum(bit[sij - 1] for sij in ksi[1:])
        if cnt % 2 != pi:
            break
    else:
        ans += 1
print(ans)
