n,m=map(int,input().split())
A=[list(map(int,input().split()))[1:] for _ in range(m)]
P=list(map(int,input().split()))

ans=0
for i in range(2**n):
    num=format(i,"b").zfill(n)
    point=0
    for j in range(m):
        cnt=0
        for k in A[j]:
            if num[k-1]=="1":cnt +=1
        if cnt%2==P[j]:point +=1
    if point==m:ans +=1
print(ans)