N,M=map(int,input().split())
switch=[]
for i in range(pow(2,M)):
    app=format(i,"b")
    app=app.zfill(M)
    switch.append(app)
cond=[]
for i in range(M):
    cond.append(list(map(int,input().split())))
p=list(map(int,input().split()))

count=0
for sw in switch:
    cond_list=[]
    for i in range(M):
        for k in cond[i]:
            cond_num+=sw[i][k]
            cond_list.append(cond_num)
    cond_list=[co % 2 for co in cond_list]
    if set(cond_list)==p:
        count+=1
print(count)
            