#include<stdio.h>
#include<stdlib.h>
#include<string.h>


typedef struct node{
    int key;
    struct node *next,*prev;
}*NodePointer;
 
NodePointer tamesi;
 
NodePointer listSearch(int key){
    NodePointer cur=tamesi->next;
    while(cur != tamesi ){
        //if ( cur == tamesi ) break;
        if(cur->key==key) return cur;
        cur=cur->next;
    }
    return tamesi;
}
 
void init(){
    tamesi=(NodePointer)malloc(sizeof(struct node));
    tamesi->next=tamesi;
    tamesi->prev=tamesi;
}
void printList(){
    NodePointer cur=tamesi->next;
    int isf=0;
    while(1){
        if(cur==tamesi) break;
        if(isf++>0) printf(" ");
        printf("%d",cur->key);
        cur=cur->next;
    }
    printf("\n");
}

void deleteNode(NodePointer t){
    if(t==tamesi) return;
    t->prev->next=t->next;
    t->next->prev=t->prev;
    free(t);
}

void deleteFirst(){
    deleteNode(tamesi->next);
}

void deleteLast(){
    deleteNode(tamesi->prev);
}

void deleteKey(int key){
    deleteNode(listSearch(key));
}

void insert(int key){
    NodePointer x=(NodePointer)malloc(sizeof(struct node));
    x->key=key;
    x->next=tamesi->next;
    tamesi->next->prev=x;
    tamesi->next=x;
    x->prev=tamesi;
}
int main(){
    int key,n,i;
    int size=0;
    char com[20];
    int np=0,nd=0;
    scanf("%d",&n);
    init();
    for(i=0;i<n;i++){
        scanf("%s%d",com,&key);
        if(com[0]=='i'){insert(key); np++; size++;}
        else if (com[0]=='d'){
            if(strlen(com)>6){
                if(com[6]=='F') deleteFirst();
                else if (com[6]=='L')deleteLast();
                }else{
                deleteKey(key); nd++;
            }
            size--;
        }
    }
    printList();
    return 0;
}
       
       
