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

typedef struct node *link;

struct node{
	int key;
	link next;
	link prev;
};

int main()
{
	int i, n, k;
	char op[20];
	
	link head = malloc(sizeof(*head));
	head->key = -1;
	head->next = NULL;
	head->prev = NULL;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++)
	{
		scanf("%s", op);
		
		if(strlen(op) > 6){
			
			if(op[6] == 'F')
			{
				if(head->next == NULL)
				{
					head->next = head->next->next;
					head->next->next->prev = head;
					free(head->next);
				}
			}else if(op[6] == 'L')
			{
				link t = head;
				while(t->next != NULL)
				{
					t = t->next;
				}
				free(t);
			}
			
		}else{
			scanf("%d", &k);
			
			if(op[0] == 'i')
			{
				link t = malloc(sizeof(*t));
				t->key = k;
				t->next = head->next;
				t->prev = head;
				head->next = t;
				if(t->next != NULL)
				{
					t->next->prev = t;
				}
			}else if(op[0] == 'd')
			{
				if(head->next != NULL)
				{
					link t = head->next;
					while(t->next != NULL)
					{
						if(t->key == k)
						{
							t->prev->next = t->next;
							t->next->prev = t->prev;
							free(t);
							break;
						}
						else
						{
							t = t->next;
						}
					}
					if(t->key == k)
					{
						t->prev->next = t->next;
						free(t);
					}
				}
			}
			
		}
		/*
		if(op[0] == 'i')
		{
			link t = malloc(sizeof(*t));
			t->key = k;
			t->next = head->next;
			t->prev = head;
			head->next = t;
			if(t->next != NULL)
			{
				t->next->prev = t;
			}
		}else if(op[0] == 'd')
		{
			if(head->next != NULL)
			{
				link t = head->next;
				while(t->next != NULL)
				{
					if(t->key == k)
					{
						t->prev->next = t->next;
						t->next->prev = t->prev;
						free(t);
						break;
					}
					else
					{
						t = t->next;
					}
				}
				if(t->key == k)
				{
					t->prev->next = t->next;
					free(t);
				}
			}
		}else if(op[6] == 'F')
		{
			if(head->next == NULL)
			{
				head->next = head->next->next;
				head->next->next->prev = head;
				free(head->next);
			}
		}else if(op[6] == 'L')
		{
			link t = head;
			while(t->next != NULL)
			{
				t = t->next;
			}
			free(t);
		}*/
		
	}
	
	if(head->next != NULL)
	{
		link t = head->next;
		while(t->next != NULL)
		{
			printf("%d ", t->key);
			t = t->next;
		}
		printf("%d\n", t->key);
	}
	
	return 0;
}