import itertools
N,M = map(int,input().split())
K =[list(map(int,input().split())) for _ in range(M)]
P = list(map(int,input().split()))

prod = list(itertools.product([0,1], repeat = N))
cnt = 0
for i in range(len(prod)):
  judge = True
  if sum(prod[i]) == 0:
    judge = False
  for j in range(M):
    temp = 0
    for k in range(K[j][0]):
      if prod[i][K[j][k+1]-1] == 1:
        temp += 1
    if temp % 2 != P[j]:
      judge = False
  if judge == True:
    cnt += 1

print(cnt) 