# 誤答
import sys 
input = sys.stdin.readline

n, m = map(int,input().split())

li = []

for i in range(2**n):
  i_bin = format(i, 'b').zfill(n)
  li.append(i_bin)
  
S = []
for i in range(m):
  s = list(map(int,input().split()))[1:]
  S.append(s)
   
p = list(map(int,input().split()))

for i in range(m):
  for j in li:
    count = 0
    for k in S[i]:
      count += int(j[k-1])
    if count % 2 != p[i]:
      li.remove(j)
      
print(len(li)) #answer