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

ans=0
for bit in range(1<<n):
    for i in range(m): #それぞれの電球について
        if P[i]!= sum([bit>>(j-1) & 1 for j in A[i]])%2:
            break
        if i==m-1:
            ans+=1

print(ans)