import sys
READ = lambda : sys.stdin.readline().strip().split()
READi = lambda : map(int, sys.stdin.readline().strip().split())

N, M = READi()
LINES = []
for i in xrange(M):
  LINES += [READi()]
P = READi()

count = 0
for i in xrange(2**N):
  bits = [(i>>b)&1 for b in xrange(N)]
  ok = True
  for line, p in zip(LINES, P):
    tmp = map(lambda x: bits[x-1], line[1:])
    ok &= (sum(tmp)%2) == p
  count += int(ok)
print count