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

typedef struct node *link;
struct node {
	int item;
	link next;
};



int main(void) {
	int n, i, d;
	link t, prev, head = NULL;
	char comm[30];

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%s", comm);
		if (comm[0] == 'i') {
			link new = malloc(sizeof(link));
			scanf("%d", &(new->item));
			new->next = head;
			head = new;
		}
		else if (comm[0] == 'd') {
			if (comm[6] == 'F') {
				t = head;
				head = head->next;
				free(t);
			}
			else if (comm[6] == 'L') {
				t = head;
				while (t->next->next != NULL) t = t->next;
				free(t->next);
				t->next = NULL;
			}
			else {
				scanf("%d", &d);
				for (t = head; t->item != d; t = t->next) prev = t;
				prev->next = t->next;
				free(t);
			}
		}
	}

	for (t = head; t != NULL; t = t->next) {
		printf("%d", t->item);
		if (t->next != NULL) printf(" ");
	}
	printf("\n");

	return 0;
}