#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
using namespace std;
struct Node{
        int val;
        Node *prev,*next;
};
Node *Null;
int insert(int key){
        Node *now;
        now=(Node *)malloc(sizeof(Node));
        now->val=key;
        now->next=Null->next;
        Null->next=now;
        Null->next->prev=now;
        now->prev=Null;
}
int main(){
        Null=(Node *)malloc(sizeof(Node));
        Null->prev=Null;
        Null->next=Null;
        int N;
        cin >> N;
        string command;int x;
        for(int i=0 ; i<N ; i++ ){
                cin >> command >> x;
                if(command=="insert"){
                        cout<<"inser"<<endl;
                        insert(x);
                }else if(command=="delete"){
                        Node *now=Null->next;
                        while(now!=Null && now->val!=x)
                                now=now->next;
                        if(now==Null)continue;
                        now->prev->next=now->next;
                        now->next->prev=now->prev;
                        free(now);
                }else if(command=="deleteFirst"){
                }else{
                }
        }
        Node *now=Null->next;
        while(now!=Null){
                cout << now->val << " ";
                now=now->next;
        }
        cout << endl;
        return 0;
}
