answer = (0..10000).map do |i|
    if i % 15 == 0
        'FizzBuzz'
    elsif i % 3 == 0
        'Fizz'
    elsif i % 5 == 0
        'Buzz'
    else
        i.to_s
    end
end

loop do
    m, n = gets.split.map(&:to_i)
    break if m == 0
    players = (1..m).to_a
    (1..n).each do |i|
        call = gets.chomp
        next if players.size == 1
        if call == answer[i]
            players.rotate!(1)
        else
            players.shift
        end
    end
    puts players.sort * ' '
end
