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

void makenode(void);
void insert(int);
void delete(int);
void print(void);

struct node{
	int key;
	struct node *next;
	struct node *prev;
};

typedef struct node * NodePointer;

NodePointer head;

int main(){
	char str[20];
	int n, i, val;
	NodePointer temp;
	
	makenode();
	scanf("%d", &n);
	
	for(i=0; i<n; i++){
		scanf("%s", str);
		if(strcmp(str, "deleteFirst") == 0){
			temp = head->next;
			temp->next->prev = temp->prev;
			temp->prev->next = temp->next;
			free(temp);
		}
		else if(strcmp(str, "deleteLast") == 0){
			temp = head->prev;
			temp->next->prev = temp->prev;
			temp->prev->next = temp->next;
			free(temp);
		}
		else{
			scanf("%d", &val);
			if(strcmp(str, "insert") == 0) insert(val);
			else if(strcmp(str, "delete") == 0) delete(val);
		}
	}
	print();
	
	return 0;
}

void makenode(void){
	head = malloc(sizeof(struct node));
	head->next = head;
	head->prev = head;
}

void insert(int val){
	NodePointer temp = malloc(sizeof(struct node));
	temp->key = val;
	temp->next = head->next;
	temp->prev = head;
	head->next->prev = temp;
	head->next = temp;
}

void delete(int val){
	NodePointer temp = head->next;
	for(; temp != head; temp = temp->next){
		if(temp->key == val){
			temp->next->prev = temp->prev;
			temp->prev->next = temp->next;
			free(temp);
			return;
		}
	}
}

void print(void){
	NodePointer temp = head->next;
	for(; temp != head->prev; temp = temp->next)
	printf("%d ", temp->key);
	printf("%d\n", temp->key);
}