#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<(int)N;i++)
#define p(S) cout<<(S)<<endl
#define ck(n,a,b) (a<=(n)&&(n)<=b)
using namespace std;
const int inf=1e9;

struct RF{
	int id,from,to;
};
int main(){
	int N;
	while(cin>>N,N){
		vector<RF> seg;
		seg.push_back({-1,0,inf});
		REP(i,0,N){
			char c;
			int id,num;
			cin>>c;
			if(c=='W'){
				cin>>id>>num;
				int i=0;
				while(num>0){
					if(seg[i].id==-1){
						int from=seg[i].from,to=seg[i].to;
						if(to-from+1<=num){
							seg[i].id=id;
							num-=to-from+1;
						}else{
							seg[i]={id,from,from+num-1};
							seg.insert(seg.begin()+i+1,{-1,from+num,to});
							num=0;
						}
					}
					i++;
				}
			}else if(c=='D'){
				cin>>id;
				REP(i,0,seg.size()){
					if(seg[i].id==id) seg[i].id=-1;
				}
			}else if(c=='R'){
				cin>>num;
				for(auto v:seg){
					if(ck(num,v.from,v.to)){
						p(v.id);
						break;
					}
				}
			}
		}
		p("");
	}

	return 0;
}