N,M=map(int,input().split())
A=[]
for i in range(M):
    b=[j for j in map(int,input().split())][1:]
    A.append(b)
p=[i for i in map(int,input().split())]

total_ans=0
for i in range(2**N):
    s=str(bin(i))[2:]
    s='0'*(N-len(s))+s
    
    ans=0
    for a, q in zip(A,p):
        
        total=0
        for item in a:
            #print(s[item-1])
            if s[item-1]=='1':
                total+=1
        #print(total,q, total%2)
        if total%2==int(q):
            ans+=1
    if ans==N:
        total_ans+=1
            
print(total_ans)  