n, m = map(int, input().split())
s = [list(map(int, input().split()))[1:] for _ in range(m)]
p = list(map(int, input().split()))

switch = [False] * n

def valid():
  for i, indices in enumerate(s):
    if sum((switch[index-1] for index in indices)) % 2 != p[i]:
      return False
  return True

cnt = 0
def dfs(start):
  global cnt
  for i in range(start, n):
    if not switch[i]:
      switch[i] = True
      if valid():
        cnt += 1  
      dfs(i+1)
      switch[i] = False
      # dfs(i+1)
      
dfs(0)
print(cnt)