N, M = map(int, input().split())
list_A=[]
for i in range(M):
    A = list(map(int, input().split()))
    list_A.append( A )

list_p = list(map(int, input().split()))

i = 0



list_func = []#スイッチ点灯の全組み合わせを入れる
cnt=0

def func(i):
    if (i == N):
        flag = True
        for k in range(M):
            sum = 0
            for j in list_A[k]:
                sum += j
            sum = sum - list_A[k][0]
            if sum %2 != list_p[k]:
                flag = False
        if flag == True:
            cnt+=1
        return
    list_func.append(1)
    func(i+1)
    list_func.pop(-1)

    list_func.append(0)
    func(i+1)
    list_func.pop(-1)

    return


func(0)
print (cnt)