#include<stdio.h>
#include<string.h>

void insert(int);
void delete(int);
void deleteF(void);
void deleteL(void);
int data[1000000],top=0,Last=0;

int main(){
	int n,i,b,x=0;
	char a[15];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s",a);
		if(strcmp(a,"insert")==0){
			scanf("%d",&b);
			insert(b);
		}else if(strcmp(a,"delete")==0){
			scanf("%d",&b);
			delete(b);
		}else if(strcmp(a,"deleteFirst")==0){
			deleteF();
		}else if(strcmp(a,"deleteLast")==0){
			deleteL();
		}
	}
	for(i=top-1;i>=Last;i--){
		if(i==Last){
			if(data[i]==NULL){
				printf("\n");
				break;
			}else{
				if(x>0)printf(" ");
				printf("%d\n",data[i]);
				break;
			}
		}else if(data[i]==NULL){
			continue;
		}else{
			 if(x>0){
			 	printf(" %d",data[i]);
			 }else{
			 x++;
			 printf("%d",data[i]);
			 }
		}
	}
	return 0;
}
void insert(int x){
	data[top]=x;
	top++;
}
void delete(int x){
	int i;
	for(i=top-1;i>=Last;i--){
		if(data[i]==x){
			data[i]=NULL;
			break;
		}
	}
}
void deleteF(){
	int i=top-1;
	while(1){
		if(data[i]!=NULL){
			data[i]=NULL;
			top=i;
			break;
		}
		i--;
	}
}
void deleteL(){
	int i=Last;
	while(1){
		if(data[i]!=NULL){
			data[i]=NULL;
			Last=i+1;
			break;
		}
		i++;
	}
}
