#include <iostream>
#include<string>
#include<list>

using namespace std;

int main()
{
	list<int> num;
	int n;
	cin >> n;

	string command;
	int comnum;

	for (int i = 1; i <= n; i++) {
		cin >> command;

		if (command == "insert") {
			cin >> comnum;
			num.push_front(comnum);
		}
		else if (command == "delete") {
			cin >> comnum;
			for (list<int>::iterator j = num.begin(); j != num.end(); j++) {
				if (*j == comnum) {
					num.erase(j);
					break;
				}
			}
		}
		else if (command == "deleteFirst") {
			num.pop_front();
		}
		else if (command == "deleteLast") {
			num.pop_back();
		}
	}

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

	cout << endl;

	return 0;
}

