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

typedef struct list
{
	int key;
	struct list *prev;
	struct list *next;
} list;

list head;
list tail;
	
void Insert(int);
void Delete(int);
void DeleteFirst();
void DeleteLast();
void PrintAllList();

int main()
{
	int i;
	int n;
	int k;
	char command[13];
	
	head.next = &tail;
	tail.prev = &head;
	
	scanf("%d", &n);
	for(i = 0; i < n; i++)
	{
		scanf("%s", command);
		
		if(strcmp(command, "insert") == 0)
		{
			scanf("%d", &k);
			Insert(k);
		}
		if(strcmp(command, "delete") == 0)
		{
			scanf("%d", &k);
			Delete(k);
		}
		if(strcmp(command, "deleteFirst") == 0)
		{
			DeleteFirst();
		}
		if(strcmp(command, "deleteLast") == 0)
		{
			DeleteLast();
		}
	}
	PrintAllList();
	
	return 0;
}

void Insert(int k)
{
	list *x;
	x = (list*)malloc(sizeof(list));
	
	x->next = head.next;
	head.next->prev = x;
	x->prev = &head;
	head.next = x;
	x->key = k;
}

void Delete(int k)
{
	list *x;
	x = head.next;
	
	while(x != &tail)
	{
		if(x->key == k)
		{
			x->prev->next = x->next;
			x->next->prev = x->prev;
			break;
		}
		x = x->next;
	}
}

void DeleteFirst()
{
	head.next->next->prev = head.next->prev;
	head.next = head.next->next;
}

void DeleteLast()
{
	tail.prev->prev->next = tail.prev->next;
	tail.prev = tail.prev->prev;
}

void PrintAllList()
{
	list *x;
	x = head.next;
	
	while(1)
	{
		printf("%d", x->key);
		if(x->next != &tail)
		{
			printf(" ");
		}
		else
		{
			printf("\n");
			break;
		}
		x = x->next;
	}
}