import sys
import itertools
input = sys.stdin.readline

N, M = map(int, input().split())
L = [list(map(int, input().split()))[1:] for m in range(M)]
p = list(map(int, input().split()))

S = [[] for i in range(N)]
for i, l in enumerate(L):
    for _l in l:
        S[_l-1].append(i)

results = []
for i in list(itertools.chain.from_iterable([list(itertools.combinations(range(N), i+1)) for i in range(N)])):
    l = [0] * M
    for j in i:
        for k in S[j]:
            l[k] += 1
    results.append(list(map(lambda _l: _l%2, l))==p)
print(results.count(True))
