from itertools import islice

R = lambda: map(int, input().split())
n, m = R()
a = [list(islice(R(), 1, None)) for _ in range(m)]
p = list(R())
r = sum(all(sum(i >> (j - 1) & 1 for  j in r) & 1 == pi
            for r, pi in zip(a, p)) for i in range(1 << n))
print(r)
