#128_C
n,m=map(int,input().split())
sw=[]
for _ in range(m):
    k,*s=map(int,input().split())
    sw.append(s)
p=list(map(int,input().split()))

ans=0
for i in range(2**n):
    L=[(i>>j)&1 for j in range(n)]
    if all([sum([L[s-1] for s in sw[k]])%2==p[k] for k in range(m)]):
        ans+=1
print(ans)