#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct node{
  int key;
  struct node *next;
  struct node *pre;
};
typedef struct node * point;
point nil;
point search(int key){
  for(point new=nil->next;new!=nil;new=new->next){
    if(new->key==key){
      return new;
    }
  }
  return nil;
}
void init(){
  nil=malloc(sizeof(struct node));
  nil->next=nil;
  nil->pre=nil;
}
void print(){
  point cur=nil->next;
  int i=0;
  while(1){
    if(cur==nil)break;
    if(i++>0)printf(" ");
    printf("%d",cur->key);
    cur=cur->next;
  }
  printf("\n");
}
void delete(point t){
  if(t==nil)return;
  t->pre->next=t->next;
  t->next->pre=t->pre;
  free(t);
}
void deleteF(){
  delete(nil->next);
}
void deleteL(){
  delete(nil->pre);
}
void deleteK(int key){
  delete(search(key));
}
void insert(int key){
  point x=malloc(sizeof(struct node));
  x->key=key;
  x->next=nil->next;
  nil->next->pre=x;
  nil->next=x;
  x->pre=nil;
}
void in(){
  int key,i,n;
  int size=0;
  char c[20];
  int np=0,nd=0;
  scanf("%d",&n);
  init();
  for(i=0;i<n;i++){
    scanf("%s%d",c,&key);
    if(c[0]=='i'){
      insert(key);
      np++;
      size++;
    }
    else if(c[0]=='d'){
      if(strlen(c)>6){
        if(c[6]=='F')deleteF();
        else if(c[6]=='L')deleteL();
      }
      else {
        deleteK(key);
        nd++;
      }
      size--;
    }
  }
}

int main(){
  in();
  print();
  return 0;
}

