#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct node{
  unsigned int *key;
  struct node *next;
  struct node *prev;
};
 typedef struct node * NodePointer;

 NodePointer c;

NodePointer search(int key){
  NodePointer a=c->next;
  while(a!=c && a->key != key){
    a=a->next;
  }
  return a;
}
 void z(){
   c=malloc(sizeof(struct node));
   c->next=c;
   c->prev=c;
 }
 void list(){
   NodePointer a=c->next;
   int b = 1;
   while(1){
     if(a==c)break;
     if(b==0)printf(" ");
     printf("%d",a->key);
     a=a->next;
     b=0;
   }
   printf("\n");
 }
  void delete(NodePointer x){
    if(x==c)return;
    x->prev->next=x->next;
    x->next->prev=x->prev;
    free(x);
  }

void first(){
  NodePointer x=c->next;
  if(x==c) return;
  delete(x);
}

void last(){
  delete(c->prev);
}

void deletekey(int key){
delete(search(key)) ;
}
void insert(int key){
  NodePointer y;
  y=malloc(sizeof(struct node));
  y->key=key;
  y->next=c->next;
  c->next->prev=y;
  c->next=y;
  y->prev=c;
}
int main(){
  int key,kin,i;
  int size=0;
  char com[20];
  int mi=0,hi=0;
  scanf("%d",&kin);
  z();
  for(i=0;i<kin;i++){
    scanf("%s%d",com,&key);
    if(com[0]=='i'){insert(key);mi++;size;}
else if(com[0]=='d'){
  if(strlen(com)>6){
    if(com[6]=='F')first();
    if(com[6]=='L')last();
  }else{
    deletekey(key); hi++;
  }
  size--;
}
}
list();
return 0;
}

