from itertools import product
n, m = map(int, input().split())
s = [list(map(lambda x: int(x) - 1, input().split()[1:])) for _ in range(m)]
p = list(map(int, input().split()))
print(sum(all(sum(b[ki] for ki in s[i]) % 2 == p[i] for i in range(m)) for b in product((True, False), repeat=n)))