/* C++ */
// ??£???????????? P97

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

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

node NIL_TOP;
node NIL_END;
// ?????????????????¨???????????????????????¨??£??? 
void initNIL(void){
	NIL_TOP.key = 0;
	NIL_TOP.next = &NIL_TOP;
	NIL_TOP.prev = &NIL_END;
	NIL_END.key = 0;
	NIL_END.next = &NIL_TOP;
	NIL_END.prev = &NIL_END;	
}

// ?????????node????????\
void insertkey(int key){
	node* x = (node*)malloc(sizeof(node));
	x->key = key;
	x->next = &NIL_TOP;
	x->prev =  NIL_TOP.prev;
	NIL_TOP.prev->next = x;
	NIL_TOP.prev = x;

}

// ????????????key??????????????????????´??????????
void deletekey(int searchkey){
	node* x = NIL_TOP.prev;
	while(x->prev != x){
		if(x->key == searchkey){
			// KEY??????????????£???
			x->next->prev = x->prev;
			x->prev->next = x->next;
			delete x;
			break;
		}else{
			x = x->prev;
		}
	}
}

// ???????????????
void deleteFirst(void){
	node* x = NIL_TOP.prev;
	x->next->prev = x->prev;
	x->prev->next = x->next;
	delete x;
}

// ????°??????????
void deleteLast(void){
	node* x = NIL_END.next;
	x->next->prev = x->prev;
	x->prev->next = x->next;
	delete x;
}

int main(int argc, char const *argv[])
{
	int inputNum;
	int loop;
	int key;
	char command[10];
	node* x;

	//????????°?????????
	scanf("%d", &inputNum);
	initNIL();

	for(loop = 0; loop < inputNum; ++loop)
	{
		scanf("%s %d", command, &key);
		if (command[0] == 'i')
		{
			insertkey(key);
		}else if( command[0] == 'd'){
			deletekey(key);
		}else if( command[0] == 'F'){
			deleteFirst();
		}else if( command[0] == 'L'){
			deleteLast();
		}
	}

	// ????????????
	x = NIL_TOP.prev;
	while(x->prev != x){
		printf("%d ", x->key );
		x = x->prev;
	}
//	printf("========== END!! (^o^)/ ==========\n");

	return 0;
}