import itertools
n,m=map(int,input().split())
l=[[0]*m for _ in range(n)]
for i in range(m):
    ltmp=list(map(int,input().split()))
    for j in ltmp[1:]:
        l[j-1][i]=1
p=list(map(int,input().split()))
lit=list(itertools.product([0,1],repeat=m))
ans=0

for i in lit:
    atmp=[]
    for j in l:
        tmp=sum([x*y for (x,y) in zip(i,j)])%2
        atmp.append(tmp)
    if atmp==p:ans+=1
print(ans)