n,m = gets.split.map(&:to_i)
sw = []

m.times do
  sw << gets.split.map(&:to_i)
end

ps = gets.split.map(&:to_i)

count = 0

0.upto(2**n-1) do |i|
  bits = i.to_s(2).rjust(n, '0').reverse
  result = true
  sw.each.with_index do |s,j|
    ons = 0
    s[1..-1].each do |m, k|
      next if k == 0
      ons += 1 if bits[m-1] == '1'
    end
    if ps[j] != ons % 2
      result = false
      break
    end
  end    
  count += 1 if result 
end

puts count