n,m = map(int,input().split())
k_s = [[int(i) for i in input().split()] for i in range(m)]
p = [int(i) for i in input().split()]

tmp = 2**n
isAll = 0
ans = 0

for i in range(tmp):
    for j in range(m):        
        #ONの時
        if ((i >> m-1-j) & 1):
            if k_s[j][0]%2 == p[j]:
                
        #OFFの時
        else:
            if k_s[j][0]%2 == p[j]:
                isAll += 1
    if isAll==n:
        ans+=1
            
print(ans)
