from itertools import product
n, m = map(int, input().split())
s = []
for _ in range(m):
    _, *t = map(int, input().split())
    s.append(t)
p = [int(i) for i in input().split()]

cnt = 0
for fl in product([0, 1], repeat=n):
    for i in range(m):
        if sum(fl[tmp - 1] for tmp in s[i]) % 2 != p[i]:
            break
    else:
        cnt += 1

print(cnt)
