#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};
typedef struct node * Node;
Node NIL;
Node Search(int key){
  Node  x;
  for(x=NIL;x->next!=NIL;x=x->next){
  if(x->next->key==key)return x->next;
  }
  return NULL;
}
void in(){
  NIL= malloc(sizeof(struct node));
  NIL->next=NIL;
  NIL->prev=NIL;
}
void print(){
  Node s=NIL->next;
  int flag=1;
  while(1){
    if (s==NIL)break;
    if (flag==0)printf(" ");
    printf("%d",s->key);
    s=s->next;
    flag=0;
  }
  printf("\n");
}
 void NODEdelete(Node x){
   x->next->prev=x->prev;
   x->prev->next=x->next;
   free(x);
 }
void delete1(){
  Node t=NIL->next;
  if (t==NIL)return;
  NODEdelete(t);
}
void delete2(){
 Node x;
  x=NIL->prev;
  NODEdelete(x);
}
void delete(int t){
  Node x;  
  x=Search(t);
  if(x!=NULL)NODEdelete(x);
}
void insert(int t){
  Node x;
  x=malloc(sizeof(struct node));
  x->key=t;
  x->next=NIL->next;
  NIL->next->prev = x;
  NIL->next=x;
  x->prev=NIL;
}

int main(){
  int n,key,i,l=0;
  char s[20];
  int p=0,d=0;
  scanf("%d", &n);
  in();
  for (i=0;i<n;i++){
    scanf("%s%d",s,&key);
    if (s[0]=='i'){
      insert(key);
      p++;
      l++;
    }
    if(s[0]=='d') {
      if(strlen(s) > 6){
	      if (s[6]=='F')delete1();
	      else if(s[6]=='L')delete2();
      }else{
	      delete(key);
        d++; 
      }
      l--;
    }
  }
  print();
  return 0;
}
