n, m = map(int,input().split())

k = []
for _ in range(m):
    k.append(list(map(int, input().split()))[0])

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

#総組み合わせ
ans = 1
for i in range(m):
    #各(k,p)に対する組み合わせ数
    com = 0
    #bit全探索（00000...0 ~ 11111...1)
    for j in range(2**k[i]):
        #onの数
        on = 0
        for h in range(0,k[i]):
            on += ((j >> h) & 1)
        #onの数%2とpの比較
        if on % 2 == p[i]:
            com += 1
    ans *= com

print(ans)



