from itertools import product

n,m = list(map(int,input().split()))
swi = []
kn = []

for _ in range(m):
    k, *sss = list(map(int,input().split()))
    swi.append(sss)
    kn.append(k)
ppp = list(map(int,input().split()))

ans = 0
sta = list(product((0, 1), repeat=n))

for st in sta:
    cnt = 0
    for l in range(m):
        for o in range(kn[l]):
            if st[swi[l][o] - 1] == 1:
                cnt += 1
        c = cnt % 2
        if c != ppp[l]:
            break
    else:
        ans += 1
print(ans)
