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

struct Node{
  int key;
  struct Node *next;
  struct Node *prev;
};

struct Node *data;

struct Node* search(int);
void In();
void Print();
void deletN(struct Node*);
void deleF();
void deleL();
void det(int);
void insert(int);


int main(){
  int i,n,key;
  int size=0,p=0,d=0;
  char rei[20];

  scanf("%d",&n);
   
   In();

   for(i=0;i<n;i++){
     scanf("%s%d",rei,&key);
    if(rei[0]=='i'){
      insert(key);
      p++;
      size++;
    }
    else if(rei[0]=='d'){
      if(strlen(rei)>6){
        if(rei[6]=='F')  deleF();
        else if(rei[6]=='L')  deleL();
      }else{
        det(key);
        d++;
      }
      size++;
    }
   }
  Print();
  return 0;
}



void Print(){
struct Node *a;
int x=0;

 a=data->next;
 while(1){
   if(a==data) {
     break;
   }
   if(x++>0){
     printf(" ");
   }
   printf("%d",a->key);
   a=a->next;
 }
 printf("\n");
}


void In(){
  data=(struct Node *)malloc(sizeof(struct Node));
  data->next=data;
  data->prev=data;
}

void deletN(struct Node *t){
  if(t==data)  return;
  t->prev->next=t->next;
  t->next->prev=t->prev;
  free(t);
}

struct Node* search(int key){
  struct Node *a;
  a=data->next;
  while(a!=data&&a->key!=key){
    a=a->next;
  }
  return a;
}

void deleF(){
  deletN(data->next);
}

void deleL(){
  deletN(data->prev);
}

void det(int key){
  deletN(search(key));
}

void insert(int key){
  struct Node *a;
  a=(struct Node *)malloc(sizeof(struct Node));
  a->key=key;
  a->next=data->next;
  data->next->prev=a;
  data->next=a;
  a->prev=data;
}
