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

typedef struct  List
{
	int key;
	struct  List *next, *prev;
}List;

List *head;

void init();
void listInsert(int);
List* listSearch(int);
void listDelete(List*);
void deleteFisrtList();
void deleteLastList();
void deleteKeyList(int);
void printList();

int main(void){
	int key, n,i,size = 0;
	char command[15];

	scanf("%d" ,&n);
	init();

	for(i=0;i<n;i++){
		scanf("%s%d", command,&key);
		if(command[0] == 'i')listInsert(key);
		else if(command[0] == 'd'){
			if(strlen(command) > 6){
				if(command[6] == 'F')deleteFisrtList();
				else if(command[6] == 'L')deleteLastList();
			}else deleteKeyList(key);

		}
	}

	printList();
	return 0;

}

void init(){
	head = (List *) malloc(sizeof(List));
	head -> next = head;
	head -> prev = head;
}

void listInsert(int key){
	List *k = (List *)malloc(sizeof(List));
	k->key = key;
	k->next =head->next;
	head -> next -> prev = k;
	head -> next = k;
	k -> prev = head;
	//printList();
}

List* listSearch(int key){
	List *target = head -> next;
	while(target != head && target -> key != key){
		target = target -> next;
	}
	return target;
}

void listDelete(List *t){
	if(t == head) return;
	t -> prev -> next = t ->next;
	t -> next ->prev = t->prev;
	free(t);
}

void deleteFisrtList(){
	listDelete(head -> next);
		//printList();
}

void deleteLastList(){
	listDelete(head -> prev);
		//printList();
}

void deleteKeyList(int key){

	listDelete(listSearch(key));
		//printList();
}

void printList(){
	List *target = head ->next;
	int i = 0;
	while(1){
		if(target == head)break;
		if(i == 0) printf("%d", target->key);
		else printf(" %d",target -> key);
		i++;
		target = target -> next;
	}
	//printf("\n");
}