n,m=map(int,input().split())
l=[]

for i in range(m):
        l.append(list(map(int,input().split())))
p=list(map(int,input().split()))

t=[]
for i in range(2**n):
        t.append(format(i,'b').zfill(n))
z=[]
p=p*(2**n)
for i in range(2**n):
        for j in range(len(l)):
                count=0
                for k in range(1,len(l[j])):
                        count+=int((t[i][l[j][k]-1]))
                z.append(count%2)
y=[]
u=[]
ans=0
for i in range(2*n):
        y.append(p[i*m:i*m+m])
        u.append(z[i*m:i*m+m])


for l in range(len(y)):
        if y[l]==u[l]:
                ans+=1
print(ans)






               



