n, m = gets.split(' ').map(&:to_i)
s = []
m.times do |i|
    tmp = gets.split(' ').map(&:to_i)
    s << tmp[1..tmp[0]]
end
p = gets.split(' ').map(&:to_i)

def solve(bit, n, m, s, p)
    m.times do |i|
        k = 0
        s[i].each do |j|
            k += 1 if (bit & (1<<j-1)) > 0
        end
        return 0 unless p[i] == (k%2)
    end
    1
end

ans = 0
(0...2**n).each do |bit|
    ans += solve(bit, n, m, s, p)
end

puts ans