#include <stdio.h>

int main(void)
{
	int i,j,k,l,a,b,c,d=0,n=0;
	int number[2000000];
	scanf("%d",&n);
	char order[12];
	

	
	for(i=0;i<n;i++){
		scanf("%s %d",order,&b);
		if(order[0]=='i') {
			number[i] = b;
		} else if(order[6] =='F') {
			i-=2;
			n-=2;
		} else if(order[6] =='L') {
			i--;
			n--;
			d++;
		} else {
			i--;
			n--;
			l=0;
			
			for(j=i;j>=0;j--) {
				if(l > 0) break;
				if(b==number[j]) {
					k = i-j;
					a=0;
					l++;
					while(k!=a++) {
						number[j+a-1] = number[j+a];
					}
					i--;
					n--;
				}
			}
		}
	}
	for(i=0; i < n-d;i++) {
		if(i==n-d-1) {
			printf("%d\n",number[n-1-i]);
		} else {
			printf("%d ",number[n-1-i]);
		}
	}
	return 0;
}
	
	
	

