from itertools import product

n, m = map(int, input().split())
ss = product([0, 1], repeat=n)
lb = []
for i in range(m):
    tmp = list(map(int, input().split()))
    k = tmp.pop(0)
    lb.append(tmp)
p = list(map(int, input().split()))
ans = 0
# n個スイッチのパターンループ
for state in ss:
    flag = True
    sc = 0
    # 電球のスイッチ条件1～iループ
    for j, l in enumerate(lb):
        # 電球の条件取り出し
        for s in l:
            sc += state[s-1]
        if sc % 2 != p[j]:
            flag = False
            break
    if flag:
        ans += 1
print(ans)