from itertools import product

n, m = map(int, input().split())
KS = [
  list(map(int, input().split()))
  for _ in range(m)
]
P = list(map(int, input().split()))

count = 0
for S in product((0, 1), repeat=n):
  if all(sum(S[s - 1] for s in ks[1:]) % 2 == p for p, ks in zip(P, KS)):
    count += 1
print(count)
    