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

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

Node *nil;

void init()
{
	nil = (Node *)malloc(sizeof(Node));
	nil->next = nil;
	nil->prev = nil;
}

Node* listSearch(int key)
{
	Node *cur = nil->next;
	while (cur != nil && cur->key != key) {
		cur = cur->next;
	}
	return cur;
}

void deleteNode(Node *x)
{
	if (x == nil) return;
	x->prev->next = x->next;
	x->next->prev = x->prev;
	free(x);
}

void delete(int key)
{
	deleteNode(listSearch(key));
}

void deleteFirst()
{
	deleteNode(nil->next);
}

void deleteLast()
{
	deleteNode(nil->prev);
}

void insert(int key)
{
	Node *x = (Node *)malloc(sizeof(Node));
	x->key = key;
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}

void print_node()
{
	Node *cur = nil->next;
	while (cur->next != nil) {
		printf("%d ", cur->key);
		cur = cur->next;
	}
	printf("%d\n", cur->key);
}


int main()
{
	int n, x, i;
	char com[100];
	init();
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%s %d", com, &x);
		if (com[0] == 'i')
			insert(x);
		else if (com[0] = 'd') {
			if (strlen(com) > 6) {
				if (com[6] == 'F') {
					deleteFirst();
				}
				else if (com[6] == 'L') {
					deleteLast();
				}
			}
			else
				delete(x);
		}
	}
	print_node();
	return 0;
}

