#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define mymalloc(p,n) {p = malloc((n)*sizeof(*p));if ((p)==NULL) {printf("not enough memory?\n"); exit(1);};}

typedef struct obj{
	struct obj *prev;
	struct obj *next;
	int key;
}obj;

typedef struct{
	struct obj *root;
	struct obj *last;
}dlist;

obj *createObj(int key){
	obj *ob;
	mymalloc(ob,1);
	ob->prev=NULL;
	ob->next=NULL;
	ob->key=key;
	return ob;
}

dlist *createDlist(){
	dlist *list;
	mymalloc(list,1);
	list->root=NULL;
	list->last=NULL;
}

void insert(dlist *list,int key){
	obj *input;
	input=createObj(key);
	if(list->root==NULL){
		list->root=input;
		list->last=input;
	}
	else{
		list->root->prev=input;
		input->next=list->root;
		list->root=input;
	}
}

void deleteX(dlist *list, int key){
	 obj *ob;
	 if(list->root==NULL){return;}
	 ob=list->root;
	 while(1){
	 	if(ob->key==key){
	 		if(ob->next==NULL){
	 			list->last=ob->prev;
	 			list->last->next=NULL;
	 		}
			else{
				ob->prev->next=ob->next;
				ob->next->prev=ob->prev;
	 		}
	 		return;
	 	}
	 	else{
	 		if(ob->next==NULL){return;}
	 		else{ob=ob->next;}
	 	}
	 }
}

void deleteL(dlist *list){
	if(list->last!=NULL){
		if(list->last->prev==NULL){
			list->last=NULL;
			list->root=NULL;
		}
		else{
			list->last=list->last->prev;
			list->last->next=NULL;
		}
	}
}

obj *deleteF(dlist *list){
	obj *output;
	if(list->root==NULL){
		return NULL;
	}
	else{
		output=list->root;
		if(list->root->next==NULL){
			list->root=NULL;
			list->last=NULL;
		}
		else{
			list->root=list->root->next;
			list->root->prev=NULL;
		}
		return output;
	}
}

main(){
	int i,n,m;
	char com[15];
	dlist *list;
	obj *ob;
	list=createDlist();
	scanf("%d ",&n);
	for(i=1;i<=n;i++){
		scanf(" %s",com);
		if(strcmp(com,"insert")==0){
			scanf(" %d",&m);
			insert(list,m);
			continue;
		}
		if(strcmp(com,"delete")==0){
			scanf(" %d",&m);
			deleteX(list,m);
			continue;
		}
		if(strcmp(com,"deleteFirst")){
			deleteF(list);
			continue;
		}
		if(strcmp(com,"deleteLast")){
			deleteL(list);
		}
	}
	
	ob=deleteF(list);
	while(1){
		printf("%d",ob->key);
		ob=deleteF(list);
		if(ob==NULL){printf("\n");break;}
		else{printf(" ");}
	}
	return 0;
}