#include<stdlib.h>
#include<stdio.h>
#include<string.h>



typedef int key;
typedef int data;

typedef struct dnode{
  struct dnode* next;
  struct dnode* prev;
  key x;
  data d;
}dnode;


typedef struct{
  dnode *head;
  dnode *tail;
}dlist;


/*key???x ,data d????????????????????????*/
dnode *make_dnode(key x,data d){
  dnode *p;
  p=malloc(sizeof(dnode));
  p->next=NULL;
  p->prev=NULL;
  p->x=x;
  p->d=d;
  return p;
}


dlist *make_dlist(){
  dlist *p;
  p=malloc(sizeof(dlist));
  p->head=NULL;
  p->tail=NULL;
  return p;
}



/*key???x ,data d???????????????dlist L?????£??\??????*/
void insert_first(dlist *L,key a,data d){
  dnode *x;
  x=make_dnode(a,d);
  x->next=L->head;
  if(L->head!=NULL) L->head->prev=x;
  else L->tail=x;
  L->head=x;
}




void delete_first(dlist *L){
  if(L->head==L->tail){
    L->head=NULL;
    L->tail=NULL;
  }
  else if(L->head!=NULL){
    L->head->next->prev=NULL;
    L->head=L->head->next;
  }
}

void delete_last(dlist *L){
  if(L->head==L->tail){
    L->head=NULL;
    L->tail=NULL;
  }
  else if(L->tail!=NULL){
    L->tail->prev->next=NULL;
    L->tail=L->tail->prev;
  }
}


void delete_x(dlist *L,key x){
  dnode *p;
  p=L->head;
  while(p!=NULL){
    if(x==p->x){
      if(p->prev!=NULL) p->prev->next=p->next;
      else L->head =p->next;
      if(p->next!=NULL) p->next->prev=p->prev;
      else{
        p->prev->next=NULL;
        L->tail=p->prev;
      }
      break;
    }
    p=p->next;
  }
}





int main(){
  int n,i,x;
  dnode *p;
  dlist *L;
  L=make_dlist();
  char order[12];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf(" %s",order);
    if(order[0]=='i'){
      scanf("%d",&x);
      insert_first(L,x,0);
    }
    else if('F'==order[6]) delete_first(L);
    else if('L'==order[6]) delete_last(L);
    else{
      scanf("%d",&x);
      delete_x(L,x);
    }
  }

  p=L->head;
  while(p->next!=NULL){
    printf("%d ",p->x);
    p=p->next;
  }
  printf("%d\n",p->x);
  return 0;
}





  