import numpy as np
from itertools import product

N, M = map(int, input().split())
sw = []

for i in range(M):
    sw.append(list(map(int, input().split()))[1:])

# 剰余がこうなれば正解
p = list(map(int, input().split()))

# スイッチの状態の組み合わせを全列挙
st = list(product([0,1],repeat=N))

ans = [False]*len(st)

for i, s in enumerate(st):
    tmp = []
    for m in range(M):
        on = 0
        for j in range(len(sw[m])):
            on += s[j]
        if (on%2)==p[m]:
            tmp.append(True)
        else:
            tmp.append(False)
    if all(tmp)==True:
        ans[i] = True

print(sum(ans))