显示代码纯文本
		
		#include<cstdio>
char chin[1500000],chout[300000],*pin=chin,*pout=chout;
int n,m,k,cnt,head,tail,pre[100001],next[100001];
void in(int &x){
	x=0;
	while(*pin<48) pin++;
	while(*pin>47) x=x*10+*pin++-48;
}
void out(int x){
	int c=0;char buf[10];
	while(x) buf[++c]=x%10+'0',x/=10;
	while(c) *pout++=buf[c--];
	*pout++='\n';
}
char getc(){
	while(*pin<60) pin++;
	return *pin++;
}
int main(){
	freopen("cline.in","r",stdin);
	freopen("cline.out","w",stdout);
	fread(pin,1,1500000,stdin);
	in(n),getc(),getc(),n--,cnt=head=tail=1;
	while(n--){
		if(getc()=='A'){
			if(getc()=='L') pre[head]=++cnt,next[cnt]=head,head=cnt;
			else next[tail]=++cnt,pre[cnt]=tail,tail=cnt;
		}
		else{
			if(getc()=='L') {in(m);for(k=head;m--;k=next[k]);head=k;}
			else {in(m);for(k=tail;m--;k=pre[k]);tail=k;}
		}
	}
	for(k=head;k!=tail;k=next[k]) out(k);out(tail);
	fwrite(chout,1,pout-chout,stdout);
}