#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;

int main(){
    list<ll> l;
    list<ll> ::iterator it;
    int N; cin >> N;
    while(N--){
        string op; cin >> op;
        int x;
        if(op == "insert"){
            cin >> x;
            l.push_front(x);
        }else if(op == "delete"){
            cin >> x;
            for (it = l.begin(); it != l.end(); it++)
                if(*it == x)
                    l.erase(it);
        }else if(op == "deleteFirst")
            l.pop_front();
        else
            l.pop_back();
    }
    for (it = l.begin(); it != l.end(); it++)
        cout << *it << ' ';
    cout << '\n';
}

