n,m=map(int,input().split())
k=[list(map(int,input().split())) for i in range(m)]
p=list(map(int,input().split()))
count=0
for i in range(2**n):
    flag=False
    judge=[]
    for j in range(m):
        for x in k[j][1:]:
            judge.append(int((i>>x-1)&1))
        finjudge=judge.count(1)
        if finjudge%2==p[j]: continue
        else: 
            flag=True
            break
    if flag: continue
    count+=1        
print(count)