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

  break if m == 0 and n == 0

  p = Array.new(m){ true }

  n.times do |i|
    next if not p[i % m]
    
    r = gets.chomp
    
    p[i % m] = 
      case true
      when (i+1) % 15 == 0; r == "FizzBuzz"
      when (i+1) % 3 == 0; r == "Fizz"
      when (i+1) % 5 == 0; r == "Buzz"
      else r.to_i == (i+1)
      end
  end

  puts p.map.with_index(1){|f, i| i if f}.select{|f| f}.sort.join(" ")
end