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

#define MAX 2000000

void insert(int);
void delete(int);
void deleteFirst(void);
void deleteLast(void);

int top=0, tail=0, L[MAX];

int main(void)
{
	int i, n, x;
	char str[12];
	
	scanf("%d",&n);
	for (i=0; i<n; i++) {
		scanf("%s",str);
		if( strcmp(str, "insert") == 0 ) {
			scanf("%d",&x);
			insert(x);
		} else if( strcmp(str, "delete") == 0 ) {
			scanf("%d",&x);
			delete(x);
		} else if( strcmp(str, "deleteFirst") == 0 ) {
			deleteFirst();
		} else if( strcmp(str, "deleteLast") == 0 ) {
			deleteLast();
		}
	}
	while( L[tail+1] == -1 ) {
		tail++;
	}
	for (i=top; i>tail+1; i--) {
		if(L[i] != -1) printf("%d ",L[i]);
	}
	printf("%d\n",L[tail+1]);
	
	return 0;
}

void insert(int x)
{
	top++;
	L[top] = x;
}

void delete(int x)
{
	int i=top;
	L[tail] = x;
	while(1) {
		if( L[i] == x ) {
			L[i] = -1;
			break;
		}
		i--;
	}
}

void deleteFirst(void)
{
	while(1) {
		if( L[top] == -1) {
			top--;
		} else {
			break;
		}
	}
	top--;
}

void deleteLast(void)
{
	while(1) {
		if( L[tail+1] == -1) {
			tail++;
		} else {
			break;
		}
	}
	tail++;
}