N, M = gets.split.map(&:to_i)
KS = M.times.map { gets.split.map(&:to_i) }
P = gets.split.map(&:to_i)

ans = 0

digits = N
max = 2 ** digits - 1
0.upto(max) do |i|
  all = true
  KS.each_with_index do |ks, idx|
    on = 0
    1.upto(ks.size - 1) do |j|
      s = ks[j]
      on += 1 if i[j - 1] == 1
    end
    all = P[idx] == 1 && on.odd? || P[idx] == 0 && on.even?
    break unless all
  end
  ans += 1 if all
end

puts ans
