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

#define REP(i,n) for(int i = 0; i < (int)n; ++i)

int main()
{
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);

	int n;
	string st;
	int x;
	cin >> n;
	list<int> L;
	list<int>::iterator it, endit;

	while(n--) {
		cin >> st;

		if(st == "insert") {
			cin >> x;
			L.push_front(x);
		}

		else if(st == "delete") {
			cin >> x;
			for(it = L.begin(), endit = L.end(); it != endit;++it) {
				if(*it == x) {
					L.erase(it);
					break;
				}
			}
		}

		else if(st == "deleteFirst") {
			L.pop_front();
		}

		else {		// deleteLast
			L.pop_back();
		}
	}

	for(it = L.begin(), endit = --L.end(); it != endit; ++it) {
		cout << *it << ' ';
	}
	cout << *it << endl;


	return 0;
}