loop do
    w, q = gets.split.map(&:to_i)
    break if w == 0
    x = 0
    sleep = {}
    q.times do
        type, id, wid = gets.chomp.split
        if type == ?s
            wid = wid.to_i
            b = (0..w-wid).find do |b|
                (((1 << wid) - 1) << b) & x == 0
            end
            if b
                puts b
                x |= (((1 << wid) - 1) << b)
                sleep[id] = [b, wid]
            else
                puts 'impossible'
            end
        else
            b, wid = sleep[id]
            x -= (((1 << wid) - 1) << b)
        end
    end
    puts 'END'
end