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

combs = []
def helper(n, sofar):
    if n == 0:
        combs.append(sofar)
        return
    else:
        helper(n-1,sofar+"0")
        helper(n-1,sofar+"1")
helper(n,"")
counter = 0
ans = []

while len(combs) > 0:
    temp = combs.pop()
    tempcheck = 1
    pindex = 0
    for index,value in enumerate(ks):
        switchon = 0
        for i, v in enumerate(value):
            if i == 0:
                continue
            if temp[i-1] == "1":
                switchon += 1

        a = switchon%2
        if p[pindex] != a:
            tempcheck = 0
            break
        pindex += 1
    if tempcheck == 1:
        counter += 1
print(counter)