from itertools import product

n, m = map(int, input().split())
ks = {}
for i in range(m):
    tmp = list(map(int, input().split()[1:]))
    ks[i] = [t-1 for t in tmp]
p = list(map(int, input().split()))


onoffs = []
for onoff in product('01', repeat=n):
    _ = [int(bin) for bin in onoff]
    onoffs.append(_)

res = 0
for i in range(len(onoffs)):
    tmp = 0
    for j in range(m):
        obj = []
        for k in range(len(ks[j])):
            obj.append(onoffs[i][k])
        if sum(obj) % 2 == p[j]:
            tmp += 1
    if tmp == m:
        res += 1

print(res)