from itertools import product
N,M=map(int,input().split())
A=[]
for _ in range(M):
    A.append(list(map(int,input().split()))[1:])
P=list(map(int,input().split()))

ans=0

for st in product([0,1],repeat=N):
    f=True
    for i in range(M):
        k=0
        for j in A[i]:
            k+=st[j-1]
        f= k//2==P[i]
        if not f:
            break
    if f:
        ans+=1

print(ans)