#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef struct node{
    int n;
    struct node *next;
}DATA;

DATA *ins(DATA *,int);
DATA *del(DATA *,int);
DATA *fir(DATA *);
DATA *las(DATA *);

int main(){
    int N,n;
    char com[20];
    char delete[]="delete";
    char insert[]="insert";
    char first[]="deleteFirst";
    char last[]="deleteLast";
    
    DATA *head;
    DATA *p;
    
    scanf("%d",&N);
    head=NULL;

    for(;N>0;N--){
        scanf("%s",com);
        if(strcmp(com,insert)==0){
            scanf("%d",&n);
            head=ins(head,n);
        }else if(strcmp(com,delete)==0){
            scanf("%d",&n);
            head=del(head,n);
        }else if(strcmp(com,first)==0){
            head=fir(head);
        }else if(strcmp(com,last)==0){
            head=las(head);
        }
    }
    while(head->next!=NULL){
        printf("%d ",head->n);
        head=head->next;
    }
    printf("%d\n",head->n);
    return 0;
    
}

DATA *ins(DATA *head,int n){
    DATA *p;
    p=malloc(sizeof(DATA));
    p->next=head;
    p->n=n;
    return p;
}

DATA *del(DATA *head,int n){
    DATA *p;
    p=head;
    while(p->next->n!=n){
        if(p->next==NULL)return head;
        p=p->next;
    }
    p->next=p->next->next;
    return head;
}
DATA *fir(DATA *head){
    DATA *p;
    p=head;
    p=head->next;
    return p;
    
    
}
DATA *las(DATA *head){
    DATA *p;
    DATA *q=NULL;
    p=head;
    while(p->next->next!=NULL)p=p->next;
    p->next=p->next->next;
    return head;
}