#1.4だと動くはずのコード
function main()
    n,m=parse.(Int,split(readline()))
    k=[parse.(Int,split(readline())) for i=1:m]
    p=parse.(Int,split(readline()))
    ans=0
    bit=[[i...] for i=Iterators.product(fill(0:1,n)...)][:]
    for i=bit
        ans+=all([isodd(count(x->i[x]==1,k[j][2:end]))==p[j] for j=1:m])
    end
    print(ans)
end
main()