#include <iostream>
#include <list>
using namespace std;


int main() {
	//コマンド数→コマンド→insertとdeleteでは要素
	int q = 0;
	int x = 0;
	char com[20];

	list<int> List;

	cin >> q;

	for (int i = 0; i < q; i++) {
		cin >> com;

		if (com[0] == 'i') {
			cin >> x;
			List.push_front(x);

		}
		else if (com[6] == 'F') {
			List.pop_front();
		}
		else if (com[6] == 'L') {
			List.pop_back();
		}
		else if (com[0] == 'd') {
			cin >> x;

			for (list<int>::iterator it = List.begin(); it != List.end(); it++) {
				if (*it == x) {
					List.erase(it);
					break; //超大事
				}
			}
		}
	}

	int i = 0;//空白作る用

	for (list<int>::iterator it = List.begin(); it != List.end(); it++) {
		if (i++) {
			cout << " ";
		}

		cout << *it;

	}

	cout << "\n";

	return 0;
}



