loop do
  w, q = gets.split.map(&:to_i)
  break if w==0 and q==0
  field = Array.new(w, nil)
  findSpace = ->d{
    space = 0
    pos = nil
    (0...w).each{|i|
      if field[i]==nil
        pos = i if pos==nil
        space += 1
        return pos if space>=d
      else
        space = 0
        pos = nil
      end
    }
    return nil
  }
  fill = ->id, pos, d{
    (pos...pos+d).each{|i| field[i] = id}
  }
  delete = ->id{
    (0...w).each{|i| field[i] = nil if field[i]==id}
  }
  
  q.times{
    type, *args = gets.split
    args.map!(&:to_i)
    
    if type=="s"
      id, d = args
      pos = findSpace[d]
      if pos
        puts pos
        fill[id, pos, d]
      else
        puts "impossible"
      end
    elsif type=="w"
      id = args[0]
      delete[id]
    end
    
  }
  puts "END"
end
