from itertools import combinations as combi
N, M = map(int, input().split())
S = [list(map(int, input().split())) for _ in range(M)]
p = list(map(int, input().split()))
def check(s):
  for i in range(M):
    temp = 0
    for j in range(1, S[i][0] + 1):
      if S[i][j] in s:
        temp += 1
    if temp % 2 != p[i]:
      return False
  return True
res = 0
for i in range(1, N + 1):
  for com in combi(range(1, N + 1), i):
    if check(set(com)) == True:
      res += 1
print(res)