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

typedef int MYDATA;

struct CELL{
	struct CELL* prev;
	struct CELL* next;
	MYDATA value;
};

struct CELL head;

void init();
void insertFirst(MYDATA x);
void insertLast(MYDATA x);
void delete(MYDATA x);
void deleteFirst();
void deleteLast();
void deleteAll();

int main(void){
	struct CELL *p;
	int i,n;
	char s[20];
	MYDATA data;

	init();

	scanf("%d",&n);

	for(i=0;i<n;i++){
		scanf("%s",s);
		if(!strcmp(s,"insert")){
				scanf("%d",&data);
				insertFirst(data);
		}else if(!strcmp(s,"delete")){
				scanf("%d",&data);
				delete(data);
		}else if(!strcmp(s,"deleteFirst")){
				deleteFirst();
		}else if(!strcmp(s,"deleteLast")){
				deleteLast();
		}
	}

	for(p = head.next;p != &head; p = p->next)
		printf("%d\n", p->value);
	return 0;
}

void init(){
	head.prev = head.next = &head;
}

void insertFirst(MYDATA x){
	struct CELL *temp;

	temp=(struct CELL*)malloc(sizeof(struct CELL));

	temp->value = x;
	temp->prev = &head;
	temp->next = head.next;
	(&head)->next->prev = temp;
	head.next = temp;
}

void insertLast(MYDATA x){
	struct CELL *temp;

	temp=(struct CELL*)malloc(sizeof(struct CELL));

	temp->value = x;
	temp->prev = head.prev;
	temp->next = &head;
	(&head)->prev->next = temp;
	head.prev = temp;
}

void delete(MYDATA x){
	struct CELL *p;

	for(p = head.next;p != &head; p = p->next){
		if(p->value==x){
			p->prev->next = p->next;
			p->next->prev = p->prev;
			break;
		}
	}
}

void deleteFirst(){
	(&head)->next = (&head)->next->next;
	(&head)->next->prev = &head;
}

void deleteLast(){
	(&head)->prev = (&head)->prev->prev;
	(&head)->prev->next = &head;
}

void deleteAll(){
	init();
}