N, M = map(int, input().split())
S = []
for i in range(M):
  k, *s = list(map(int, input().split()))
  S.append(s)

P = list(map(int, input().split()))
ans = 0
for i in range(2**N):
  if all([
    sum([i & 2 ** (n-1) > 0 for n in S[m]]) % 2 == P[m] for m in range(M)
  ]):
    ans += 1

print(ans)