# coding: utf-8
# Your code here!
n,m=map(int,input().split())
l=[]
for i in range(m):
    a=input().split()
    l.append(a)
p=list(map(int,input().split()))

l2=[0]*10
ans=0
num=0
for a in range(0,2):
    for b in range(0,2):
        for c in range(0,2):
            for d in range(0,2):
                for e in range(0,2):
                    for f in range(0,2):
                        for g in range(0,2):
                            for h in range(0,2):
                                for i in range(0,2):
                                    for j in range(0,2):
                                        if num>2**n-1:
                                            break
                                        else:
                                           l2[0]=a
                                           l2[1]=b
                                           l2[2]=c
                                           l2[3]=d
                                           l2[4]=e
                                           l2[5]=f
                                           l2[6]=g
                                           l2[7]=h
                                           l2[8]=i
                                           l2[9]=j
                                           num+=1
                                         
for aa in l2:
    for bb in l:
        pp=0
        nn=0
        for cc in range(len(bb)):
            pp=pp+int(bb[cc-1])
        if pp%2==p[nn]:
            ans+=1
        nn+=1
print(ans)