#include <stdio.h>

#define MAXCMD 2000000

struct tagLinkList
{
	int forward;
	int data;
	int back;
}LinkList[MAXCMD];
int head = -1;
int tail = 0;
int deletePos[20] = { -1 };

void InsertData(int data)
{
	int now, next;
	now = head;
	next = ++head;

	LinkList[next].data = data;
	LinkList[next].forward = tail;

	if (next == tail)
	{
		LinkList[next].back = tail;
	}
	else
	{
		LinkList[next].back = now;

		LinkList[now].forward = next;
		LinkList[tail].back = next;
	}
}

void del(int i)
{
	int f = LinkList[i].forward;
	int b = LinkList[i].back;

	LinkList[f].back = b;
	LinkList[b].forward = f;

	LinkList[i].forward = -1;
	LinkList[i].data = -1;
	LinkList[i].back = -1;

	if (i == head)
	{
		head = b;
	}
	if (i == tail)
	{
		tail = f;
	}
}

void DeleteData(int d)
{
	for (int i = head;;)
	{
		int b = LinkList[i].back;

		if (LinkList[i].data == d)
		{
			del(i);
			break;
		}
		i = b;
		if (i == head)
		{
			break;
		}
	}
}

void DeleteFirst()
{
	del(head);
}

void DeleteLast()
{
	del(tail);
}

int main()
{
	int N;
	char Command[15];
	int Data;
	
	scanf("%d", &N);
	for (int i = 0; i < N; i++)
	{
		LinkList[i].forward = -1;
		LinkList[i].data = -1;
		LinkList[i].back = -1;
	}
	
	for (int i = 0; i < N; i++)
	{
		scanf("%s", Command);
		if (Command[0] == 'i')
		{
			scanf("%d",&Data);
			InsertData(Data);
		}
		else if (Command[6] == 'F')
		{
			DeleteFirst();
		}
		else if (Command[6] == 'L')
		{
			DeleteLast();
		}
		else
		{
			scanf("%d", &Data);
			DeleteData(Data);
		}
	}

	for (int i = head;;)
	{
		printf("%d", LinkList[i].data);
		i = LinkList[i].back;
		if (i == head)
		{
			break;
		}
		printf(" ");
	}
	printf("\n");
	return 0;
}