n, $m = gets.strip.split.map(&:to_i)
k = []
$s = []

$m.times do |i|
    ks = gets.strip.split.map(&:to_i)
    k << ks[0]
    $s << ks[1..-1]
end
$p = gets.strip.split.map(&:to_i)

$swstate = [0] * n
$count = 0
def ns(ni)
    if ni == 0 then
        $swstate[ni] = 0
        while true do
            # check
            flag = true
            $m.times do |i|
                flag = flag && ($s[i].count{ |sidx| $swstate[sidx - 1] > 0 } % 2 == $p[i])
            end
            $count += 1 if flag
            break if $swstate[ni] == 1
            $swstate[ni] = 1
        end
    else
        $swstate[ni] = 0
        ns(ni - 1)
        $swstate[ni] = 1
        ns(ni - 1)
    end
end

ns(n - 1)
puts $count
