//1W153021 KOYA IWASE
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct LIST{//?§????????????£?¨?
  struct LIST *prev;//??????????´??????????????????????
  struct LIST *next;//??????????´??????????????????????
  int key;
};

struct LIST *list;//???????????????????????????
void insert(int x);//?????¨????????¢??°?????£?¨?
void delete(int x);
void deleteFirst();
void deleteLast();
void printList();

int main(void){
  list=(struct LIST *)malloc(sizeof(struct LIST));//?????¢????¢????
  list->next=list;//?????????????´???????????????????????????????
  list->prev=list;
  int key,N;
  char comm[20];
  scanf("%d",&N);//????????°????????????
  for(int i=0;i<N;i++){//?????????????????????
    scanf("%s%d",comm,&key);
    if(comm[0]=='i'){//insert
      insert(key);
    }else{
      if(strlen(comm)>6){
        if(comm[6]=='F'){//deleteFirst
          deleteFirst();
        }else if(comm[6]=='L'){//deleteLast
          deleteLast();
        }
      }else{//delete
        delete(key);
      }
    }
  }
  printList();
  return 0;
}

void insert(int x){//????????¨?¬????????´????????????¢????????????????´?????????\??????
  struct LIST *y = (struct LIST *)malloc(sizeof(struct LIST));//?????\??????????????°????????????????¢????
    y->key = x;
    y->next = list->next;
    list->next->prev = y;
    list->next = y;
    y->prev = list;
}

void delete(int x){//????????????key?????????
  struct LIST *i = list->next;//list????¬????????´?????????????????±?????????????
  while(i != list && i->key != x ) {//???????????????key??¨?????´??????????´??????¢???
      i = i ->next;
    }
  if(i==list)return;//???????????????????????????????????£?????´??????i???list??????????????????????????£??????????????§?????????????????¢??°?????????
  i->prev->next=i->next;
  i->next->prev=i->prev;
  free(i);//?????¢???????§£???
}

void deleteFirst(){
  struct LIST *t = list->next;//list????¬????????´?????????????????????????????´??????????
  if(t==list)return;//list->next=list?????????????´???????????????§?????????????????¢??°?????????
  t->prev->next=t->next;
  t->next->prev=t->prev;
  free(t);//?????¢???????§£???
}

void deleteLast(){
  struct LIST *t = list->prev;//list??????????????????????????????????´??????????
  if(t==list)return;//?????????????§????????????????????´???????????????§??¢??°?????????
  t->prev->next=t->next;
  t->next->prev=t->prev;
  free(t);//?????¢???????§£???
}

void printList(){//????????????????´??????????
  struct LIST *i;
  i = list->next;//??????????¬????????????????????´?
  int j = 0;
  while(1) {
    if (i == list) break;//i=list?????´??????????´????????????????????????????????????????????????????
    if(j++ > 0) printf(" ");//?????????????????????????????????????????????????????§???????????????
    printf("%d", i->key);//key?????????
    i = i->next;//?¬????????´????
  }
  printf("\n");
}