from itertools import product
N, M = map(int, input().split())
k = []
s = []
for i in range(M):
    ks = list(map(int, input().split()))
    k.append(ks[0])
    s.append(ks[1:])
p = list(map(int, input().split()))

ans = 0
for t in product([0, 1], repeat=N):
    sw = {i+1: t[i] for i in range(N)}
    flg = 1
    num = 0
    for ind in range(M):
        for j in s[ind]:
            num += sw[j]
        if num % 2 != p[ind]:
            flg = 0
            break
    if flg:
        ans += 1
print(ans)