#include <stdio.h>
#include <stdlib.h>
void insert(int _vl);
void deleteF(void);
void delete(int _vl);
void deleteL(void);
struct Nd{
  struct Nd* next;
  struct Nd* prev;
  int value;
};
struct Nd* head;
struct Nd* tail;
int main(){
  int i,n,tmpValue;
  char str[20];
  struct Nd* Nd;
  head = (struct Nd*)malloc(sizeof(struct Nd));
  tail = (struct Nd*)malloc(sizeof(struct Nd));
  head->next = tail;
  head->prev = NULL;
  tail->next=NULL;
  tail->prev=head;
  head->value = 0;
  tail->value=0;
 
  scanf("%d",&n);
 
  for(i=0; i<n; i++){
    scanf("%s",str);
    if(!strcmp(str,"insert")){
      scanf("%d",&tmpValue);
      insert(tmpValue);
    }else if(!strcmp(str,"deleteF")){
      deleteF();
    }else if(!strcmp(str,"deleteL")){
      deleteL();
    }else if(!strcmp(str,"delete")){
      scanf("%d",&tmpValue);
      delete(tmpValue);
    }
  }
  for(Nd=head->next; Nd != tail; Nd=Nd->next){
    printf("%d",Nd->value);
    if(Nd->next!=tail){
      printf(" ");
    }
  }
  printf("\n");
  return 0;
}
void insert(int _vl){
  struct Nd* newNd;
  struct Nd* tmpNd;
  newNd = (struct Nd*)malloc(sizeof(struct Nd));
  tmpNd = head->next;
  if(tmpNd != NULL){
    tmpNd->prev = newNd;
  }
  head->next = newNd;
  newNd->next = tmpNd;
  newNd->prev = head;
  newNd->value = _vl;
}
void deleteF(){
  struct Nd* Nd;
  Nd=head->next;
  if(head != NULL){
    head->next= Nd->next;
  }
  if(Nd->next != NULL){
    Nd->next->prev = head;
  }
}
void delete(int _vl){
  struct Nd* Nd;
  struct Nd* tmpNd;
  for(Nd=head->next; Nd != NULL; Nd=Nd->next){
    if(Nd->value == _vl){
      tmpNd = Nd->prev;
      if(tmpNd != NULL){
    tmpNd->next = Nd->next;
      }
      if(Nd->next != NULL){
    Nd->next->prev = tmpNd;
      }
      break;
    }
  }
}
void deleteL(){
  struct Nd* tmpNd;
  tmpNd=tail->prev;
  tail->prev=tmpNd->prev;
  tmpNd->prev->next=tail;
}