N, M = map(int, input().split())

k=[]
for i in range(M):
  temp = list(map(int, input().split()))
  k.append(temp[1:])

p = list(map(int, input().split()))

result = 0
for i in range(2 ** N):
  for j, v in enumerate(k):
    s = [1 for temp in v if 2 ** (temp-1) & i]
    if sum(s) % 2 != p[j]:
      break
  else :
    result += 1
  

print(result)