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

lights = m.times.map { gets.split.map(&:to_i).drop(1) }
parities = gets.split.map(&:to_i)

count = 0
0.upto(2**n-1) do |b|
  if lights.each.with_index.all? { |switches, i|
       c = switches.count { |s| ((1 << (s-1)) & b) != 0 }
       c % 2 == parities[i]
     }
    count += 1
  end
end
puts count
