n,m=map(int,input().split())
s=[]
for i in range(m):
    ks=list(map(int,input().split()))
    s.append(ks[1:])
p=list(map(int,input().split()))
ans=0
for i in range(1<<n):
    cnt=0
    for j in range(m):
        for k in s[j]:
            if i&1<<(k-1):
                cnt+=1
        if cnt%2!=p[j]:
            break
    else:
        ans+=1

print(ans)
