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

typedef struct PLIST{
	struct PLIST *pre;
	struct PLIST *next;
	int key;
}plist;

plist *head;
plist *tail;

int compStr(char *str0, char *str1){
	int i = 0;
	for( i = 0; str0[i] != '\0' || str1[i] != '\0'; i++ ){
		if( str0[i] != str1[i] ){ return 0; }
	}
	if( str0[i] != str1[i] ){ return 0; }
	return 1;
}

void insert(plist *p, plist *next){
	if( p == NULL ){ return; }
	if( next != NULL ){
		p->pre = NULL;
		p->next = next;
		next->pre = p;
	}else{
		p->pre = NULL;
		p->next = NULL;
		tail = p;
	}
	head = p;
	return;
}

void delete(plist *p){
	if( p == NULL ){ return; }
	if( p->pre != NULL ){
		p->pre->next = p->next;
	}else{
		head = p->next;
	}
	if( p->next != NULL ){
		p->next->pre = p->pre;
	}else{
		tail = p->pre;
	}
	free(p);
	return;
}

int main(){
	int i = 0;
	int n = 0;
	char com[1024];
	int x = 0;
	scanf("%d", &n);
	plist *temp;
	for( i = 0; i < n; i++ ){
		scanf("%s", com);
		if( compStr(com, "insert\0") ){
			scanf("%d", &x);
			temp = (plist*)malloc(sizeof(plist));
			temp->key = x;
			if( head != NULL ){
				insert(temp, head);
			}else{
				insert(temp, NULL);
			}
		}
		if( compStr(com, "delete\0") ){
			scanf("%d", &x);
			temp = head;
			while( (temp = temp->next) != NULL ){
				if( temp->key == x ){ break; }
			}
			delete(temp);
		}
		if( compStr(com, "deleteFirst\0") ){
			delete(head);
		}
		if( compStr(com, "deleteLast\0") ){
			delete(tail);
		}
	}
	temp = head;
	if( temp != NULL ){ printf("%d", temp->key); }
	while( (temp = temp->next) != NULL ){ printf(" %d", temp->key); }
	printf("\n");
	return 0;
}