#include<stdio.h>
#include<stdlib.h>
#include <string.h>
#include<math.h>
#define scani(x) scanf("%d",&x)
#define scanc(x) scanf("%s",x)
#define printi(x) printf("%d",x)
#define printin(x) printf("%d\n",x)
#define printc(x) printf("%s",x)
#define repd(i,n,m) for(int i = n; i > m; i--)
#define repu(i,n,m) for(int i = 0; i < m; i++)
#define allprintu(i,n,m,a) for(int i = 0; i < m; i++){if(i != m-1){printf("%d ",a[i]);}else{printf("%d\n",a[i]);}}
#define allprintd(i,n,m,a) for(int i = n; i > m; i--){if(i != 0){printf("%d ",a[i]);}else{printf("%d\n",a[i]);}}
#define cnt 2000000

struct node{
	unsigned int key;
	struct node *prev, *next;
};
typedef struct node* NodePointer;
NodePointer nil;

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

NodePointer ListSearch(int key){
	NodePointer p = nil->next;
	while(1){
		if(p == nil) break;
		if(p->key == key){
			return p;
		}
		p = p->next;
	}
	return NULL;
}

void DeleteNode(NodePointer p){
	if(p == nil) return;
	p->prev->next = p->next;
	p->next->prev = p->prev;
	free(p);
}

void Insert(int key){
	NodePointer p;
	p = (NodePointer)malloc(sizeof(NodePointer));
	p->key = key;
	nil->next->prev = p;
	p->next =nil->next;
	p->prev = nil;
	nil->next = p;
}

void Delete(int key){
	NodePointer p = ListSearch(key);
	if(p != NULL){
		DeleteNode(p);
	}


}
void DeleteFirst(){
	NodePointer p = nil->next;
	if(p == nil) return;
	DeleteNode(p);
}

void DeleteLast(){
	NodePointer p = nil->prev;
	if(p == nil) return;
	DeleteNode(p);
}



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");
}


int main(void){
	int n,key;
	int size = 0;
	char com[20];
	int np = 0; 
	int nd = 0;
	scani(n);
	InIt();
	repu(i,0,n){
		scanf("%s%d",com,&key);
		if(com[0] == 'i'){
			Insert(key);
			np++;
			size++;
		}else if(com[0] == 'd'){
			if(strlen(com) > 6){
				if(com[6] == 'F') DeleteFirst();
				else if(com[6] == 'L') DeleteLast();
			}else{
				Delete(key);
				nd++;
			}
			size--;
		}
	}
	PrintList();
	return 0;
}
