import itertools
N,M=map(int,input().split())
ks=list(list(map(int,input().split())) for _ in range(M))
P=list(map(int,input().split()))
L=[0,1]
LL=list(itertools.product(L,repeat=N))
ans=0
sum=[]
msum=0
for I in LL:
    sum=[]
    for J in ks:
        msum=0
        for k in range(1,J[0]+1):
            msum+=I[J[k]-1]
            sum.append(msum)
    if all(sum[i]%2==P[i] for i in range(M)):
        ans+=1
print(ans)