n, m = gets.split.map &:to_i
lm = []
m.times {
    _, *s =  gets.split.map &:to_i
    lm << s
}
p = gets.split.map &:to_i
ans = 0
(0..2**n - 1).each{ |e|
    sum = Array.new(m, 0)
    (0..n-1).each{ |i|
        if e[i] == 1
            (0..m-1).each{ |j|
                if lm[j].include? i+1
                    sum[j] += 1
                end
            }
        end
    }
    s = true
    (0..m-1).each{ |i|
        s &= p[i] == sum[i] % 2
    }
    ans += 1 if s
}

puts ans