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

#define COMMAND_SIZE 12

typedef struct node{
	int key;
	struct node* prev;
	struct node* next;
}node_t;

node_t* head;

void insert(int key){
	node_t* new_node=(node_t*)malloc(sizeof(node_t));
	node_t* tmp;
	
	new_node->key=key;
	
	tmp=head->next;
	head->next=new_node;
	new_node->prev=head;
	
	new_node->next=tmp;
	tmp->prev=new_node;
	
}

void del(int key){
	node_t* n;
	node_t* tmp;
	
	for(n=head->next;n!=head;n=n->next){
		if(n->key==key){
			break;
		}
		else if(n->next==head){
			return;
		}
	}
	
	tmp=n->prev;
	tmp->next=n->next;
	n->next->prev=tmp;
	
	free(n);
	
	return;
}

void del_first(){
	node_t* tmp=head->next;
	head->next=tmp->next;
	tmp->next->prev=head;
	
	free(tmp);
}

void del_last(){
	node_t* tail=head->prev;
	
	tail->prev->next=head;
	head->prev=tail->prev;
	
	free(tail);
	return;
}

int main(void){
	int n;
	scanf("%d",&n);
	
	char command[COMMAND_SIZE];
	int num;
	
	node_t dummy;
	head=&dummy;
	head->prev=head;
	head->next=head;
	insert(-1);
	
		for(int i=0;i<n;i++){
		if(scanf("%s",command)==EOF){
			break;
		}
		
		if(strcmp(command,"deleteFirst")!=0 && strcmp(command,"deleteLast")!=0){
			scanf("%d",&num);
		}
		
		if(strcmp(command,"insert")==0){
			insert(num);
		}
		else if(strcmp(command,"delete")==0){
			del(num);
		}
		else if(strcmp(command,"deleteFirst")==0){
			del_first();
		}
		else if(strcmp(command,"deleteLast")==0){
			del_last();
		}else{
			printf("error:コマンド不一致\n");
			return -1;
		}
			
			
	}
	
	for(node_t* i=head->next;i->next!=head;i=i->next){
		printf("%d",i->key);
		
		if(i->next->next!=head){
			printf(" ");
		}else{
			printf("\n");
			break;
		}
	}
	
	return 0;
}

