import numpy as np

N,M = list(map(int, input().split()))

ks = []
switch_list = [[] for i in range(M)]
for i in range(M):
    ks.append(list(map(int, input().split())))
    for j in range(10-ks[i][0]):
        switch_list[i].append(0)
    for j in range(ks[i][0]):
        switch_list[i].insert(10-ks[i][j+1],1)
p = list(map(int, input().split()))

ans = 0
for i in range(2**N):
    flg = True
    binary = format(i, 'b').zfill(10)
    binary = list(map(int, binary))
    for j in range(M):
        on = np.logical_and(switch_list[j], binary)
        total_on = sum(on)
        if total_on%2 != p[j]:
            flg = False
            break
    if flg:
        ans += 1
print(ans)