n, m = map(int, input().split())
s = [list(map(int, input().split()))[1:] for _ in range(m)]
p = list(map(int, input().split()))
count = 0

for _ in range(2 ** n):
    pattern = list(map(int, list(bin(_)[2:].zfill(n))))
    if all(sum(pattern[sw2 - 1] for sw2 in ss ) % 2 == pp for ss, pp in zip(s, p)):
        count += 1
print(count)