import itertools

n, m = input().split()
n, m = int(n), int(m)
 
bulbs = []
 
for i in range(m):
    l = input().split()
    arr = [int(x) for x in l][1:]
    bulbs.append(arr)

needs = [int(x) for x in input().split()]
 
combos = 0

def test(lis):
  curr = 0
  for i in range(m):
    need = needs[i]
    for b in bulbs[i]:
      if lis[b-1] == 1:
        curr += 1
    if curr % 2 != need:
      return False
  return True
  
for i in itertools.product([0, 1], repeat=n):
  if test(list(i)):
    combos += 1

print(combos)