#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 1 << 30;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


struct Doubly_linked_list
{
    vector<long long> l;
    long long front = 0;
    long long back  = 0;
    public :
    Doubly_linked_list(){
        l.resize(1e6+5);
    }



    void insert(long long a){
        l[front] = a;
        ++front;
        return;
    }

    void del(long long a){
        for(long long pos = front;pos >= back;--pos){
            if(l[pos] == a){
                l[pos] = -1;
                break;
            }
        }
        return;
    }

    void del_first(){
        while(l[front] == -1 || l[front] == 0)--front;
        l[front] = -1;
        //--front;
        return;
    }
    
    void del_last(){
        while(l[back] == -1)++back;
        l[back] = -1;
        ++back;
        return;
    }

    vector<long long> ret(){
        vector<long long> res;
        for(long long i = front;i >= back;--i)if(l[i] != -1 && l[i] != 0)res.emplace_back(l[i]);
        return res;
    }
    ////前後反転していることに留意
    //void merge(vector<long long> &l){
    //    vector<long long> after;
    //    for(ll i = 0;i < l.size();i++)if(l[i] != -1)after.emplace_back(l[i]);
    //    l = after;
    //    return;
    //}
    //
    //void insert(long long a){
    //    l.emplace_back(a);
    //    //merge(l);
    //}
    //
    //void del(long long a){
    //    //for(auto &i : l)if(i == a){
    //    //    i = -1;
    //    //    break;
    //    //}
    //    per(i,l.size()-1){
    //        if(l[i] == a){
    //            l[i] = -1;
    //            break;
    //        }
    //    }
    //    //merge(l);
    //    return;
    //}
    //
    //void del_first(){
    //    //l.back() = -1;
    //    per(i,l.size()-1){
    //        if(l[i] != -1){
    //            l[i] = -1;
    //            break;
    //        }
    //    }
    //    return;
    //    //merge(l);
    //}
    //
    //void del_last(){
    //    //l.front() =  -1;
    //    rep(i,l.size()){
    //        if(l[i] != -1){
    //            l[i] = -1;
    //            break;
    //        }
    //    }
    //    return;
    //    //merge(l);
    //}
};


//ミョ(-ω- ?)
int main() {
    //入出力高速化
    cin.tie(nullptr) ;
    ios::sync_with_stdio(false) ;
    ll n;cin >> n;
    Doubly_linked_list dlist;
    //cerr << "\n";
    rep(i,n){
        string s;cin >> s;
        ll a = -1;
        if(s != "deleteFirst" && s != "deleteLast")cin >> a;
        ++a;
        if(s == "insert")dlist.insert(a);
        if(s == "delete")dlist.del(a);
        if(s == "deleteFirst")dlist.del_first();
        if(s == "deleteLast") dlist.del_last();

        //================================>
        //cerr << "[COMMAND]" << s;
        //if(a != -1){cerr << " "<< a -1 ;}
        //cerr << "\n";
        //auto v = dlist.ret();//cerr << "\033[32m" << "[DEBUG]";
        ////reverse(v.begin(),v.end());
        //rep(i,v.size()) //cerr << (i?" ": "") << v[i] -1;
        //cerr << "\33[m" << "\n";
        //<================================
    }
    auto v = dlist.ret();
    //reverse(v.begin(),v.end());
    rep(i,v.size()) cout << (i?" ": "") << v[i] -1;
    cout << "\n";
    return 0;
}


Measured memory_bytes: 12756