N, M = gets.split.map(&:to_i)
array = []

def isOK(p,t,l)
    sum = 0
    t.each{|x| sum += l[x-1]}
    return sum % 2 == p
end

M.times{
    target = gets.split.map(&:to_i)
    target.shift
    array.push(target)
}
plist = gets.split.map(&:to_i)

list = [0,1].repeated_permutation(N).to_a
array.each.with_index{|target_list,index|
    list.select!{|x|
        isOK(plist[index], target_list, x)
    }
}

puts list.size