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

struct node{
	unsigned int k;
	struct node *next, *prev;	
};

typedef struct node * NodePointer;
NodePointer nil;

NodePointer search(int key){
	NodePointer a,b;
	
	b = nil;
	a = b->next;
	
	while(a!=nil){
		if(a->k == key)
			return b;
		b = a;
		a = b->next;
	}
	return NULL;
}

void init(){
	nil = malloc(sizeof(struct node));
	nil->next = nil;
	nil->prev = nil;
	nil->k = -1;
}

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

void deleteNode(NodePointer t){
/* your code */
}

void deleteFirst(){
	NodePointer a,b;
	
	a = nil->next;
	b = a->next;
	b->prev = nil;
	nil->next = b;
	
	free(a);
}

void deleteLast(){
	NodePointer a,b;
	
	a = nil->prev;
	b = a->prev;
	b->next = nil;
	nil->prev = b;
	
	free(a);
}

void delete(int key){
	NodePointer a,b,c;
	
	if(nil->next->k == key){
		deleteFirst();
		return;
	}
	
	a = search(key);
	if(a == NULL){
		return;
	}
	
	c = a->next;
	b = a->next->next;
	a->next = b;
	b->prev = a;
	
	free(c);
}

void insert(int key){
	NodePointer a,b;
	a = malloc(sizeof(struct node));
	a->k = key;
	b = nil->next;
	nil->next = a;
	a->prev = nil;
	a->next = b;
	b->prev = a;
	
}

int main(){
	int key, n, i, size, np, nd;
	size = np = nd = 0;
	char inst[20];
	
	scanf("%d", &n);
	init();
	for ( i = 0; i < n; i++ ){
		scanf("%s%d", inst, &key);
		if ( inst[0] == 'i' ) {insert(key); np++; size++;}
		else if ( inst[0] == 'd' ) {
			if (strlen(inst) > 6){
				if ( inst[6] == 'F' ) deleteFirst();
			else if ( inst[6] == 'L' ) deleteLast();
		} else 
			delete(key); nd++;
		size--;
		}
	}
	printList();
		
	return 0;
}
