while l = gets
  w, k = l.split.map(&:to_i)
  break if w == 0 && k == 0
  cats = Hash.new
  wall = Array.new
  wall << [0, w]
  k.times do
    l = gets.split
    s = l.shift
    if s == "s"
       id, wide = l.map(&:to_i)
      (0..wall.size-1).each do |i|
        left = wall[i][0]
        len = wall[i][1]
        if len >= wide
          cats[id] = [left,wide]
          if len > wide
            wall[i] = [left+wide,len-wide] 
          else
            wall.delete_at(i)
          end
          break
        end
      end
      if cats[id] == nil
        puts "impossible"
      else
        puts cats[id][0]
      end
    else
      id = l[0].to_i
      wall.push(cats[id])
      wall.sort!
      cnt = 0
      (wall.size-1).times do |i|
        left = wall[i-cnt][0]
        len = wall[i-cnt][1]
        n_left = wall[i+1-cnt][0]
        n_len = wall[i+1-cnt][1]
        if left+len == n_left
          wall[i-cnt,2] = [[left,len+n_len]]
          cnt += 1
        end
      end
    end
  end
  puts "END"
end