from itertools import product

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

k = []
s = []
for _ in range(M):
    t = list(map(int, input().split()))
    k.append(t[0])
    s.append(t[1:])

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

ans = sum(
    all(
        sum(
            t[j - 1]
            for j in range(k[i])
        ) % 2 == p[i]
        for i in range(M)
    )
    for t in product(range(2), repeat=N)
)

print(ans)
