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

typedef struct List List;
struct List{
	List *next;
	List *prev;
	int val;
};

List list;

void initialize(){
	list.next = &list;
	list.prev = &list;
}

void insert(int x){
	//list ha val nasi
	List *p;
	p = (List*)malloc(sizeof(List));
	p->val = x;
	p->prev = &list;

	list.next->prev = p;
	p->next = list.next;
	list.next = p;
}

void delete(int x){
	List *p;
	for(p=list.next;p!=&list;p=p->next){
		if(p->val==x){
			p->prev->next = p->next;
			p->next->prev = p->prev;
		}
	}
}

void deleteFirst(){
	List *p;
	p = list.next;
	list.next = p->next;
	p->next->prev = &list;
}

void deleteLast(){
	List *p;
	p = list.prev;
	list.prev = p->prev;
	p->prev->next = &list;
}

void display(){
	List *p;
	for(p=list.next;p!=&list;p=p->next){
		printf("%d",p->val);
		if(p->next!=&list)printf(" ");
		else printf("\n");
	}
}

int main(){
	int i,n;
	char command[20];
	int x;
	initialize();
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s %d",command,&x);
		if(!strcmp(command,"insert")){
			insert(x);
		}else if(!strcmp(command,"delete")){
			delete(x);
		}else if(!strcmp(command,"deleteFirst")){
			deleteFirst();
		}else if(!strcmp(command,"deleteLast")){
			deleteLast();
		}else{
			printf("no command\n");
		}
	}
	display();
}