def fizzbuzz(n)
  if n % 5 == 0 && n % 3 == 0
    n = :FizzBuzz
  elsif n % 5 == 0
    n = :Buzz
  elsif n % 3 == 0
    n = :Fizz
  end

  n
end

# puts (1..100).map { |i| fizzbuzz(i) }

while line = gets
  m, n = line.chomp.split.map(&:to_i)
  break if m == 0 && n == 0

  a = [*1..m]
  i = 0
  c = 1

  n.times do
    break unless a.size > 1

    s = gets.chomp

    unless s == fizzbuzz(c).to_s
      a.delete_at(i)
      i = (i + n - 1) % a.size
    else
      i = (i + 1) % a.size
    end

    c += 1
  end

  puts a.join(' ')
end