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

typedef struct Node {
	int key;
	struct Node *prev, *next;
}Node;

Node *nil;

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;
	nil->next = x;
	x->prev = nil;
}

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

void deleteNode(Node *t){
	if(t == nil) return;
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deleteFirst(){
	deleteNode(nil->next);
}

void deleteLast(){
	deleteNode(nil->prev);
}

void deleteKey(int key){
	deleteNode(listSearch(key));
}

int main(){
	int i,j=0,num,key;
	char order[15];
	Node *cur;
	
	scanf("%d",&num);
	init();
	for(i=0; i<num; i++){
		scanf("%s%d",order,&key);
		if(order[0]=='i') insert(key);
		else if(order[0]=='d'){
		if(order[6]=='F') deleteFirst();
		else if(order[6]=='L') deleteLast();
		else deleteKey(key);
		}
	}
	cur  = nil->next;
	while(1){
		if(cur == nil) break;
		if(j++ > 0) printf(" ");
		printf("%d",cur->key);
		cur = cur->next;
	}
	printf("\n");
		
	return 0;
}