#include<stdio.h>
   
int main(void){
	int i,j,k,n,x,y,z,num = 0;
	char c[12];
	scanf("%d",&n);
	int a[n];
	for(i=0;i<n;i++){
		scanf("%s %d",c,&k);
		if(c[0]=='i'){
			a[i] = k;
		}else if(c[6]=='F'){
			i-=2;
			n-=2;
		}else if(c[6]=='L'){
			i--;
			n--;
			num++;
		}else{
			i--;
			n--;
			x=0;
			for(j=i;j>=0;j--){
				if(x>0)break;
				if(k==a[j]){
					y=i-j;
					z=0;
					x++;
					while(y!=z){
						z++;
						a[j+z-1]=a[j+1+z-1];
					}
					i--;
					n--;
				}
			}
		}
	}
	for(i=0;i<n-num;i++){
		if(i==n-num-1){
			printf("%d\n",a[n-1-i]);
		}else{
			printf("%d ",a[n-1-i]);
		}
	}
	return 0;
}