import numpy as np

temp=input().split()
N=int(temp[0])
M=int(temp[1])

A=np.zeros((M, N))

for i in range(M):
  temp=list(map(int, input().split()))
  for j in range(1, temp[0]+1):
    A[i, temp[j]-1]=1
    
    
p=list(map(int, input().split()))

counter=0
for i in range(pow(2, N)):
  temp=format(i, '0'+str(N)+'b')
  s=[int(temp[j]) for j in range(N)]
  
  a=np.dot(A, s)%2
  
  if all(p==a):
    counter+=1
    
print(counter)