import itertools
target = (0, 1)
N,M = map(int,input().split())
sk_ = [list(map(int,input().split())) for _ in range(M)]
P_ = list(map(int,input().split()))
max_n = 0
state = list(itertools.product(target,repeat=N))
#print(state)
for i in state:
  #print('state : {}'.format(i))
  num = 0
  ons = 0
  for j in range(M):
    #print('m : {}'.format(j))
    for s in sk_[j][1:]:
      #print('s : {}'.format(s))
      if i[s-1] == 1:
        num += 1
    if num%2 == P_[j]:
      ons += 1
  #print('ons : {}'.format(ons))
  if ons == M:
    max_n += 1
    
print(max_n)

