N,M = map(int,input().split())
swis = [list(map(int,input().split()))[1:] for _ in range(M)]
need = list(map(int,input().split()))

ans = 0
for i in range(1<<N):#すいっちのくみあわせ
  for j in range(M):#でんきゅうをみてく
    rel=0
    for k in swis[j]:
      if i & (1<<(k-1)) != 0:
        rel+=1
        
      if rel%2 != need[j]:
        break
  else:
     ans+=1
      
print(ans)
        
