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

struct list{
    int key;
    struct list *next,*back;
};

struct list *list;
 
struct list * search(int key){
    struct list *x = list->next;
    while(x!=list && x->key!=key) x = x->next;
    return x;
}

void init(){
    list = (struct list *)malloc(sizeof(struct list));
    list->next = list;
    list->back = list;
}

void print(){
    struct list *x = list->next;
    int i = 0;
    while(1){
       if(x == list) break;
       if(i++ > 0) printf(" ");
        printf("%d", x->key);
        x = x->next;
    }
    printf("\n");
}

void insert(int key){
    struct list *x = (struct list *)malloc(sizeof(struct list));
    x->key = key;
    x->next = list->next;
    list->next->back = x;
    list->next = x;
    x->back = list;
}

void delete(struct list *x){
    if(x == list) return;
    x->back->next = x->next;
    x->next->back = x->back;
    free(x);
}

int main(){
    int key, n, i;
    char ins[20];
    scanf("%d", &n);
    init();
 
    for(i = 0; i < n; i++){
      scanf("%s %d", ins, &key);
      if(ins[0] == 'i'){
          insert(key);
      }
      else if(ins[0] == 'd'){
          if(strlen(ins) > 6){
              if(ins[6] == 'F') delete(list->next);
              else if(ins[6] == 'L') delete(list->back);
          }else {
              delete(search(key));
          }
      }
    }
    print();
    return 0;
}