from itertools import product

N,M = map(int, input().split() )
k_list = []
for i in range(M):
    k_i_list = [int(s) for s in input().split()]
    k_list.append(k_i_list)

p_list =  [int(t) for t in input().split()]

counter = 0
temp_counter = 0
isOn = 1
## スイッチすべての可能性に対して
for u in product([0,1], repeat=N):
    isOn = 1
    ## 各電球に対して
    for v in range(M):
        ## 各電球が対応するスイッチに対して
        for w in range(int(k_list[v][0])):
            temp_counter += u[w]
        if temp_counter %2 != p_list[v]:
            isOn = 0
            # break
    if isOn == 1:
        counter += 1

print(str(counter))