n,m=map(int,input().split())
K=[list(map(int,input().split())) for __ in range(m)]
p=list(map(int,input().split()))

a=set()

for idx,k in enumerate(K):
    pre = set()
    for i in range(2 ** n):
        pre_ans = 0
        for j in k[1:]:
            pre_ans += i>>(j-1)&1
        if pre_ans%2 == p[idx]:
            pre.add(bin(i))
    if len(a)==0:
        a=pre
    else:
        a=a&pre

print(len(a))
