#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct node{
	int key;
	struct node *prev,*next;
};
typedef struct node node;
node *nil;
void init();
void insert(int key);
void deletef(int key);
void deleteFirst();
void deleteLast();
void printKey();
node *listSearch(int key);
int main(){
	int n,i,j=0,key;
	char a[15];
	scanf("%d",&n);
	init();
	for(i=0;i<n;i++){
		scanf("%s",a);
		if(strlen(a)==6){
			scanf("%d",&key);
			if(a[0]=='i'){
				insert(key);
			}
			else{
				deletef(key);
			}
		}
		else if(a[6]=='F'){
			deleteFirst();
		}
		else if(a[6]=='L'){
			deleteLast();
		}
	}
	printKey();
	return 0;
} 
void init(){
    nil=(node *)malloc(sizeof(node));
    nil->next=nil;
    nil->prev=nil;
}
void insert(int key){
	node *x=(node *)malloc(sizeof(node));
	x->key=key;
	x->next=nil->next;
	nil->next->prev=x;
	x->prev=nil;
	nil->next=x;
}
void deletef(int key){
	node *x=listSearch(key);
	if(x==nil)return;
	x->prev->next=x->next;
	x->next->prev=x->prev;
	free(x);
}
void deleteFirst(){
	node *x=nil->next;
	x->prev->next=x->next;
	x->next->prev=x->prev;
	free(x);
}
void deleteLast(){
	node *x=nil->prev;
	x->prev->next=x->next;
	x->next->prev=x->prev;
	free(x);
}
node *listSearch(int key){
	node *current=nil->next;
	while(current->key!=key&&current!=nil){
		current=current->next;
	}
	return current;
}
void printKey(){
	node *current=nil->next;
	int t=0;
	while(current!=nil){
		if(t>0)
		printf(" ");
		printf("%d",current->key);
		current=current->next;
		t++;
	}
	printf("\n");
}

