while n = gets.to_i
  break if n == 0
  arr = []
  arr << [0, 1000000001, -1]
  n.times do
    l = gets.split
    cmd = l.shift
    case cmd
    when "W"
      x, s = l.map(&:to_i)
      pos = 0
      loop do
        p, size, y = arr[pos]
        if y == -1
          arr[pos][2] = x
          if size <= s
            s -= size
          else
            arr[pos][1] = s
            arr.insert(pos + 1, [p + s, size - s, -1])
            break
          end
        end
        pos += 1
      end
    when "D"
      x = l[0].to_i
      arr.size.times do |i|
        arr[i][2] = -1 if arr[i][2] == x
      end
    when "R"
      sec = l[0].to_i
      arr.size.times do |i|
        p, size, y = arr[i]
        if p <= sec && sec - p < size
          p y
          break
        end
      end
    end
  end
  puts
end