import itertools
n,m = map(int,input().split())
l = [tuple(map(int, input().split())) for _ in range(m)]
judge = tuple(map(int, input().split()))
count =0
switch = list(itertools.product([0,1], repeat=n))
for i in range (2**n):
    #スイッチ全探索
    for j in range(m):
        #各電球に焦点
        for k in range(l[j][0]):
            #電球のスイッチ条件に焦点
            cnt =0
            cnt += switch[i][k]
        if cnt%2 != judge[j]:
            break
    else:
        if j == m-1:
            count += 1
print(count)
