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

struct Node
{
	long long data;
	struct Node *next, *prev;
};
typedef struct Node *List;

List init()
{
	List list;
	list = (List)malloc(sizeof(struct Node));
	list->next = list;
	list->prev = list;
	return list;
}

void insert(List head, long long x)
{
	List tmp;
	tmp = (List)malloc(sizeof(struct Node));
	tmp->data = x;
	tmp->next = head->next;
	head->next->prev = tmp;
	head->next = tmp;
	tmp->prev = head;
}

void delete(List list, long long x)
{
	if (list->next == list->prev)
		return;
	List tmp;
	tmp = list->next;
	
	while (tmp != list && tmp->data != x)
		tmp = tmp->next;
	if (tmp == list)
		return;

	tmp->prev->next = tmp->next;
	tmp->next->prev = tmp->prev;
	free(tmp);
}

void deleteFirst(List list)
{
	if (list->next == list)
		return;
	List tmp;
	tmp = list->next;
	tmp->prev->next = tmp->next;
	tmp->next->prev = tmp->prev;
	free(tmp);
}

void deleteLast(List list)
{
	if (list->next == list)
		return;
	List tmp;
	tmp = list->prev;
	tmp->prev->next = tmp->next;
	tmp->next->prev = tmp->prev;
	free(tmp);
}

void print(List list)
{
	if (list->next == list)
		return;
	List tmp;
	tmp = list;
	while (tmp->next!=list)
	{
		tmp = tmp->next;
		if (tmp != list->next)
			printf(" ");
		printf("%lld", tmp->data);
	}
	printf("\n");
}

void solve()
{
	List list;
	list = init();
	long long n, x;
	char s1[20];
	
	scanf("%lld", &n);
	for (long long i = 0; i < n; i++)
	{
		scanf("%s", s1); 
		if (strcmp(s1, "insert") == 0)
			scanf("%lld", &x),insert(list, x);
		if (strcmp(s1, "delete") == 0)
			scanf("%lld", &x),delete(list, x);
		if (strcmp(s1, "deleteFirst") == 0)
			deleteFirst(list);
		if (strcmp(s1, "deleteLast") == 0)
			deleteLast(list);
	}
	print(list);
}

int main()
{
	solve();
}
