n,m = map(int, input().split())
dic_s = {}
for i  in range(n):
    dic_s[i] = []
for i in range(m):
    a = list(map(int, input().split()[1:]))
    for num in a:
        dic_s[num-1].append(i)
p = list(map(int, input().split()))
oridinal = []
for tmp in p:
    if tmp == 0:
        oridinal.append(True)
    else:
        oridinal.append(False)

total = 0

for i in range(2 ** n): # n個のスイッチの組み合わせ
    judge = [oridinal[i] for i in range(m)]
    for j in range(n):  # このループが一番のポイント
        if ((i >> j) & 1):  # 1だったら(オンだったら)
            for d in dic_s[j]: #jにつながる電球つく
                judge[d] = not judge[d]
    if all(judge):      # ぜんぶついた！
        total+=1
        break
print(total)