n, m = map(int, input().split())
ks = [list(map(int, input().split())) for i in range(m)]
p=list(map(int, input().split()))
ans=0
for i in range(1<<n):
    val=[]
    tmp=i
    for j in range(n):
        val.append(tmp%2)
        tmp//=2
    if all(sum(val[k-1] for k in ks[j][1:])%2==p[j] for j in range(m)):
        ans+=1
print(ans)