// Slower C++ solution:
#include <iostream>



using namespace std;



class LightList

{

private:

	const static int INVALID = -1;

	int front, back, size;

	int *allocate_array;



public:

	LightList(int size) : 

		front(0), back(0), size(0)

	{

		allocate_array = new int[size];

	}

	~LightList()

	{

		delete[] allocate_array;

	}

	void insert(int x)

	{

		allocate_array[front] = x;

		front++;

		size++;

	}

	void remove(int x)

	{

		for (int i = front - 1; i >= back; i--) {

			if (allocate_array[i] == x) {

				allocate_array[i] = INVALID;

				if (i == front - 1)

					front--;

				if (i == back)

					back++;

				break;

			}

		}

	}

	void deleteFirst()

	{

		if (size > 0) {

			front--;

			size--;

		}

	}

	void deleteLast()

	{

		if (size > 0) {

			back++;

			size--;

		}

	}

	void print()

	{

		int i = front - 1;

		while (i >= back && allocate_array[i] == INVALID) i--;

		cout << allocate_array[i];

		i--;

		for (; i >= back; i--) {

			if (allocate_array[i] != INVALID)

				cout << ' ' << allocate_array[i];

		}

		cout << endl;

	}

	/*

	void debug_print()

	{

		cout << "front = " << front

			<< "back = " << back

			<< "size = " << size << endl;

		for (int i = 10; i >= 0; i--) {

				cout << allocate_array[i] << (i == back ? '\0' : ' ');

		}

		cout << endl;

	}

	*/

};



int main()

{

	ios::sync_with_stdio(false);

	cin.tie(0);



	int n, size = 1000020;

	cin >> n;

	if (n < 1000020) size = n;

	LightList number_list(size);



	for (int i = 0; i < n; i++) {

		char command[12];

		int x;

		cin >> command;

		if (command[0] == 'i') { // insert x

			cin >> x;

			number_list.insert(x);

		}

		else { // delete???

			switch (command[6]) {

			case '\0': // delete x

				cin >> x;

				number_list.remove(x);

				break;

			case 'F': // deleteFirst

				number_list.deleteFirst();

				break;

			case 'L': // deleteLast

				number_list.deleteLast();

				break;

			}

		}

	}

//	number_list.debug_print();

	number_list.print();

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.1021018771689683x):
#include <stdio.h>



using namespace std;



int main()

{

	const static int INVALID = -1;

	int front = 0, back = 0;

	int *allocate_array;



	int n, size = 1000020;

	scanf("%d", &n);

	if (n < 1000020) size = n;



	allocate_array = new int[size];

	char command[12];

	int x;



	for (int i = 0; i < n; i++) {

		scanf("%s", command);

		if (command[0] == 'i') { // insert x

			scanf("%d", &x);

			allocate_array[front] = x;

			front++;

			size++;

		}

		else { // delete???

			switch (command[6]) {

			case '\0': // delete x

				scanf("%d", &x);

				for (int i = front - 1; i >= back; i--) {

					if (allocate_array[i] == x) {

						allocate_array[i] = INVALID;

						if (i == front - 1)

							front--;

						if (i == back)

							back++;

						break;

					}

				}

				break;

			case 'F': // deleteFirst

				if (size > 0) {

					front--;

					size--;

				}

				break;

			case 'L': // deleteLast

				if (size > 0) {

					back++;

					size--;

				}

				break;

			}

		}

	}

	int i = front - 1;

	while (i >= back && allocate_array[i] == INVALID) i--;

	printf("%d", allocate_array[i]);

	i--;

	for (; i >= back; i--) {

		if (allocate_array[i] != INVALID)

			printf(" %d", allocate_array[i]);

	}

	putchar('\n');



	delete[] allocate_array;

	return 0;

}