import itertools

n, m = map(int,input().split())

sw = [[] for _ in range(M)]
for i in range(m):
    sw[i] = list(map(int,input().split()[1:])) #k不要
     
p = list(map(int,input().split()))

res = 0
for tpl in itertools.product([0,1],repeat=n):
    bl = True
    for i in range(m):
        s = sum([tpl[s-1] for s in sw[i]]) # 電球iを計算
        if (s-p[i])%2 != 0:
            bl = False
            break
    if bl:
        res += 1
print(res)