from itertools import product
N,M = map(int,input().split())
cc = []
for i in range(M):
  ll = list(map(int,input().split()))
  cc.append(ll)
p = list(map(int,input().split()))
count = 0
for i in product('01',repeat = N):
  on = 0
  bulb = 0
  for j in range(M):
    for k in range(cc[j][0]):
      if i[cc[m][l+1]-1] == 1:
        on += 1
    if on % 2 == p[j]:
      bulb += 1
  if bulb == M:
    count += 1
print(count)
    
      
  
