N,M = map(int,input().split())
comb = ["0"*(N-len(format(i,"b")))+format(i,"b") for i in range(2**N)]
result = 0
setting = list()
for i in range(M):
    setting.append(list(map(int,input().split())))
p = list(map(int,input().split()))
for i in comb:
    l = 0
    flag = 0
    for j in setting:
        count = 0
        for k in j:
            if i[k-1] =="1":
                count +=1
        if count % 2 == p[l] :
            flag += 1
        else:
            flag = 0
        l +=1
    if flag ==M:
        result +=1
print(result)