def check(state,switch, check)
  switch.map { |i| state[i - 1] }.count('1') % 2 == check
end

n,m = gets.split(' ').map(&:to_i)
switch_list = []
m.times do
  switch_list << gets.split(' ').map(&:to_i)[1..-1]
end
check_list = gets.split(' ').map(&:to_i)

count = 0
(0...2 ** n).each do |num|
  flag = true
  (0...m).each do |j|
    unless check("%#{n}b" % num, switch_list[j], check_list[j])
      flag = false
      break
    end
  end
  count += 1 if flag
end

puts count