var
s,i,l,r,now,k,long:longint;
ch,x,dir:char;
q:array[0..1000000]of longint;
begin
assign(input,'cline.in'); reset(input);
assign(output,'cline.out'); rewrite(output);
readln(s);
l:=100000; r:=100000;
for i:=1 to s do
begin
read(ch);
case ch of
'A':begin
readln(x,dir);
inc(now);
case dir of
'L':begin
dec(l);
q[l]:=now;
end;
'R':begin
inc(r);
q[r]:=now;
end;
end;
end;
'D':begin
readln(x,dir,k);
long:=r-l;
if k>=long then
begin
k:=long;
l:=100000;
r:=100000;
end;
if dir='L' then
begin
if k<100000-l then l:=l+k
else l:=l+k+1;
end;
if dir='R' then
begin
if k<r-100000 then r:=r-k
else r:=r-k-1;
end;
end;
end;
end;
for i:=l to r do
if q[i]<>0 then writeln(q[i]);
close(input);
close(output);
end.