N, M = gets.split(" ").map(&:to_i)
s = []
M.times do |i|
    s[i] = gets.split(" ").map(&:to_i)
    s[i].shift
end
p = gets.split(" ").map(&:to_i)
ans = 0

(2**N).times do |i|
    i = i.to_s(2)
    while i.length < N do
        i = "0" + i
    end
    ok = 0
    for j in (0...M) do
        count = 0
        s[j].each do |sw|
            count += 1 if i[sw - 1] == "1"
        end
        ok += 1 if count % 2 == p[j] #&& count > 0
    end
    puts i if ok == M
    ans += 1 if ok == M
end

puts ans