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

struct Node{
	unsigned int key;
	struct Node *next;
	struct Node *prev;
};

typedef struct Node  *NodePointer;

NodePointer nil;

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

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

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

void deleteNode(NodePointer t)
{
	t->next->prev=t->prev;
	t->prev->next=t->next;
	free(t);
}
 
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 deleteKey(int key)
{
	NodePointer x = nil->next;
	
	for(x=nil->next; x!=nil; x=x->next){
		if(x->key==key){
			if(x->next==nil){
				deleteLast();
			}
			else if(x->prev==nil){
				deleteFirst();
			}
			else{
				deleteNode(x);
			}
			break;
		}
	}
}

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