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

typedef struct dou
{
	int key;
	struct dou  *next, *prev;
}list;

list *y;

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

void deleteKey(int key)
{
	list *x = y->next;
	
	while(x != y && x->key != key)
	{
		x = x->next;
	}
	
	if(x != y)
	{
		x->prev->next = x->next;
		x->next->prev = x->prev;
		free(x);
	}
	
	
}

void deleteFirst()
{
	list *x = y->next;
	
	if(x != y)
	{
		x->prev->next = x->next;
		x->next->prev = x->prev;
		free(x);
	}
}

void deleteLast()
{
	list *x = y->prev;
	
	if(x != y)
	{
		x->prev->next = x->next;
		x->next->prev = x->prev;
		free(x);
	}
}

int main(void)
{
	list a;
	int n, i, key, np, nd, size;
	char command[20];
	
	np=0;
	nd=0;
	size=0;
	
	scanf("%d", &n);
	
	y=(list *)malloc(sizeof(list));
	y->next = y;
	y->prev = y;
	
	for(i =0; i< n; i++)
	{
		scanf("%s %d", command, &key);
		
		if(strcmp("insert", command)==0)
		{
			insert(key);
			np++;
			size++;
		}
		else if(strcmp("delete", command)==0)
		{
			deleteKey(key);
			nd++;
			size--;
		}
		else if(strcmp("deleteFirst", command)==0)
		{
			deleteFirst();
			size--;
		}
		else if(strcmp("deleteLast", command)==0)
		{
			deleteLast();
			size--;
		}
		
	}
	
	list *x = y->next;
	int j = 0;
	
	for(;;)
	{
		if(x==y)
		{
			break;
		}
		
		if(j > 0)
		{
			printf(" ");
		}
		
		j++;
	
		printf("%d", x->key);
		x=x->next;
		
	}
	
	printf("\n");
	
	return 0;
	
}



