N, M = (int(i) for i in input().split())
  
dict_rel = dict()
for i in range(M):
  dict_rel[i+1] = [int(j) for j in input().split()][1:]
list_cond = [int(i) for i in input().split()]

#print(dict_rel)
#print(list_cond)

list_pattern = [[] for j in range(2**N)]

for i in range(len(list_pattern)):
  b = bin(i)[2:].zfill(N)
  list_pattern[i] = [int(k) for k in b]

#print(list_pattern)

num_full = 0
for pattern in list_pattern:
  flg = True
  for light in dict_rel.keys():
    num_on = 0
    for i in range(len(dict_rel[light])):
      if pattern[i] == 1:
        num_on += 1
    if list_cond[light-1] != num_on%2:
      flg = False
      break
  if flg == True:
    num_full += 1

print(num_full)
