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
    l = l.map(&:to_i)
    if s == "s"
      (0..wall.size-1).each do |i|
        if wall[i][1] >= l[1]
          cats[l[0]] = [wall[i][0], l[1]]
          wall[i] = [wall[i][0]+l[1], wall[i][1]-l[1]] if wall[i][1]-l[1] > 0
          break
        end
      end
      if cats[l[0]] == nil
        puts "impossible"
      else
        puts cats[l[0]][0]
      end
    else
      wall.push(cats[l[0]])
      wall.delete(nil)
      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