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

typedef struct note{
	unsigned int key;
	struct note *next;
	struct note *prev;
} *NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
	NodePointer cur = nil->next;
	while(cur != nil){
		if(cur->key == key) return cur;
		cur = cur->next;
	}
	return NULL;
}

void init(){
	nil = malloc(sizeof(NodePointer));
	nil->next = nil;
	nil->prev = nil;
}

void printList(){
	NodePointer cur = nil->next;
	int isf = 1;
	while(1){
		if(cur == nil) break;
		if(!isf) printf(" ");
		printf("%d", cur->key);
		cur = cur->next;
		isf = 0;
	}
	printf("\n");
}

void deleteNode(NodePointer t){
	NodePointer ne, pr;
	ne = t->next;
	pr = t->prev;
	pr->next = ne;
	ne->prev = pr;
}

void deleteFirst(){
	NodePointer t = nil->next;
	if(t == nil) return;
	deleteNode(t);
}

void deleteLast(){
	NodePointer t = nil->prev;
	if(t == nil) return;
	deleteNode(t);
}

void delete(int key){
	NodePointer t = listSearch(key);
	if(t) deleteNode(t);
}

void insert(int key){
	NodePointer x;
	x = malloc(sizeof(NodePointer));
	x->key = key;
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}
int main(void){
	int key, n, i;
	char cmd[20];
	scanf("%d", &n);
	init();
	for(i = 0; i < n; i++){
		scanf("%s%d", cmd, &key);
		if(cmd[0] == 'i') insert(key);
		else if(cmd[0] == 'd')
		{
			if(strlen(cmd) > 6)
			{
				if(cmd[6] == 'F') deleteFirst();
				else if(cmd[6] == 'L') deleteLast();
			}
			else delete(key);
		}
	}
	printList();
	return 0;
}

