n,m=gets.split.map(&:to_i)
s=Array.new(m)
k=Array.new(m)
m.times do |i|
    k[i],*s[i]=gets.split.map(&:to_i)
    end
p=gets.split.map(&:to_i)
ans=0
(0..2**n-1 ).each do |i|
f=true
m.times do |j|
    cnt=0
    k[j].times do |l|
        cnt^=1 if i[s[j][l]-1]==1
        end
    f=false if cnt!=p[j]
    end
ans+=1 if f
end
puts ans