n,m=list(map(int,input().split()))
switch=[]
for i in range(2**n):
    kouho=[]
    for j in range(n):
        if (i>>j & 1):
            kouho.append(1)
        else:
            kouho.append(0)
    switch.append(kouho)

kyu=[]
for i in range(m):
    kyu.append(list(map(int,input().split())))
p=list(map(int,input().split()))

ans=0
num=0
q=[]
for i in range(len(switch)):
    for j in range(m):
        for k in range(1,len(kyu[j])):
            num=num+switch[i][kyu[j][k]-1]   
        q.append(num%2)
        num=0
    q.reverse()
    if p==q:
      ans=ans+1
    q=[]
    
        
            
print(ans)    
    
    
    
    
        
        
        