#include<bits/stdc++.h>
#define B begin()
#define Y second
#define E end()
#define X first
#define M (1e9)
using namespace std;
map<int,int>::iterator p;
map<int,int> m;

int Read(int x){
  for(p=m.B;p!=m.E;p++)
    if(x<=(*p).X)return (*p).Y;
}

void Del(int x){
  for(p=m.B;p!=m.E;p++)
    if((*p).Y==x)(*p).Y=-1;
}

void Write(int x,int y){
  int s=-1;
  for(p=m.B;p!=m.E;p++){
    if(!y)return;
    if((*p).Y!=-1){
      s=(*p).X;
      continue;
    }
    if((*p).X-s>=y)m[s+y]=x,y=0;
    else y-=(*p).X-s,(*p).Y=x;
    s=(*p).X;
  }
}

int main(){
  int n,a,b;
  string s;
  while(1){
    cin>>n;
    if(!n)break;
    m.clear();
    m[M]=-1;
    while(n--){
      cin>>s;
      if(s=="R")cin>>a,cout<<Read(a)<<endl;
      if(s=="W")cin>>a>>b,Write(a,b);
      if(s=="D")cin>>a,Del(a);
    }
    cout<<endl;
  }
  return 0;
}