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

typedef struct _node
{
	int value;
	struct _node * next;
	struct _node * prev;
} node_t;

node_t *head;
node_t *p;


void Init()
{
//	fprintf( stdout, "init finished\n" );
	head = malloc( sizeof( node_t ) );
	head->next = NULL;
	head->prev = NULL;
	head->value = 100;
	p = head;
}

void Insert( int x )
{
//	fprintf( stdout, "insert started\n" );
	node_t *newnode;
	newnode = malloc( sizeof( node_t ) );
	p->next = newnode;
	newnode->value = x;
	newnode->next = NULL;
	newnode->prev = p;
	p = newnode;
}

void Delete( int x )
{
//	fprintf( stdout, "delete started\n");
	node_t *pointer, tmp;
	pointer = head;

	while ( pointer->next != NULL )
	{
		pointer = pointer->next;
		if( pointer->value == x )
		{
			pointer->prev->next = pointer->next;
			pointer->next->prev = pointer->prev;
			free( pointer );
		}
	}
}

void DeleteFirst()
{
//	fprintf( stdout, "deletefirst started\n");
	node_t *pointer;

	pointer = head->next;
	head->next = pointer->next;
	pointer->next->prev = head;
	free( pointer );
}


void DeleteLast()
{
	node_t *pointer;
//	fprintf( stdout, "deletelast started\n");
	pointer = p;
	p = pointer->prev;
	p->next = NULL;
	free( pointer );
}

void PrintValue()
{
	node_t *pointer;
	pointer = p;

	while( pointer != head )
	{
		fprintf( stdout, "%d ", pointer->value );
		pointer = pointer->prev; 
	}

	//fprintf( stdout, "\n");
}

int main()
{
	int n, i = 0, num;
	char s[12];

	Init();

	scanf( "%d", &n );
	while ( i < n )
	{
		scanf( "%s", s );
		if ( strcmp( s, "insert" ) == 0 )
		{
			scanf( "%d", &num );
			Insert( num );
		}
		else if ( strcmp( s, "delete" ) == 0 )
		{
			scanf( "%d", &num );
			Delete( num );
		}
		else if ( strcmp( s, "deleteFirst" ) == 0 )
		{
			DeleteFirst();
		}
		else if ( strcmp( s, "deleteLast" ) == 0 )
		{
			DeleteLast();
		}
	//	PrintValue();
		i = i + 1;
	}

	PrintValue();

	return 0;
}