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

typedef struct Node* NodePointer;//??¢?????¬???

typedef struct Node{
	int key;
	NodePointer next;
	NodePointer pre;
} Node;

NodePointer head;
NodePointer last;

void init(){
	head = malloc(sizeof(Node));
	last = malloc(sizeof(Node));
	head->next = last;
	last->pre = head;
}

NodePointer makeNode(int key){
	NodePointer tmp = malloc(sizeof(Node));
	tmp->next = tmp->pre = NULL;
	tmp->key = key;
	return tmp;
}

void insert(NodePointer ins, int key){
	NodePointer newnode = makeNode(key);
	NodePointer tmp = ins->next;
	ins->next = newnode;
	newnode->pre = ins;
	newnode->next = tmp;
	tmp->pre = newnode;

}
void delete(NodePointer p){
	NodePointer s = p->pre;
	NodePointer tmp = s->next;
	s->next = tmp;
	tmp->pre = s;
	free(p);
}





int main(){
	int n,i;
	int num;
	char command[100];
	NodePointer p;
	init();
	scanf(" %d ", &n);
	while(n--){
		scanf(" %s ", command);
		if (!strcmp(command,"insert")){
			scanf(" %d ", &num);
			insert(head,num);
		}else if (!strcmp(command, "delete")){
			scanf(" %d ", &num);
			for(p = head->next; p != last; p = p->next){
				if (p->key == num){//delete????????°???????????????????????????????????????
					delete(p);
					break;
				}
			}
		}else if (!strcmp(command, "deleteFirst")){
			delete(head->next);
		}else if (!strcmp(command, "deleteLast")){
			delete(last->pre);
		}

	}

	for (p = head->next; p != last; p = p->next){
			printf(p==head->next? "%d":" %d", p->key);
		}
		printf("\n");
	return 0;
}