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

#define MAX_k 1000000000 
#define MAX_l 1000000
#define MAX_m 2000000
 
struct node{
  unsigned int k;
  struct node *next;
  struct node *prev;
};
 
typedef struct node*NodePointer;
 
NodePointer NIL;

void init(void); 
void insert(int);


void del(int);
void delFirst(void);
void delLast(void);
void printList(void);

void delNode(NodePointer);
NodePointer Search(int);


int main(){
  int k, n, i;
  int size = 0;
  int np=0, nd=0;
 
  char come[20];

  scanf("%d",&n);
 
  init();
 
  for(i=0;i < n;i++){
    scanf("%s%d", come, &k);
    if(0 >= k && k >= MAX_k){
      printf("error");
    }
    if(come[0]=='i'){
      insert(k);
      np++;
      size++;
    }
    else if(come[0]== 'd'){
      if(strlen(come)>6){
    if(come[6]=='F'){
      delFirst();    
    }
    else if(come[6]=='L'){
      delLast();
    }
      } else {
    del(k);
    nd++; 
      }
      size--;
    }
    if(size > MAX_l){
      printf("error"); 
    }
  }
 
  if(!( np+nd <= MAX_m)){
    printf("error");
  }
  if(!( nd <= 20)){
    printf("error");
  }
  printList();
 
  return 0;
}
 
void insert(int k){
  NodePointer x1;
  x1 = malloc(sizeof(struct node));
  x1->k = k;
  x1->next = NIL->next;
  NIL->next->prev = x1;
  NIL->next = x1;
  x1->prev = NIL;
}

void delFirst(){
  NodePointer a;
  a = NIL->next;
  if ( a == NIL ) return;
  delNode(a);
}
 
void delLast(){
  NodePointer a;
  a = NIL->prev;
  if ( a == NIL ) return;
  delNode(a);
}
 

void del(int k){
  NodePointer a;
  a = Search(k);
  if ( a == NIL ) return;
  delNode(a);
}
 
 void delNode(NodePointer a){
  a->prev->next = a->next;
  a->next->prev = a->prev;
  free(a);
}

NodePointer Search(int k){
  NodePointer c;
  c = NIL->next;
  while(c != NIL && c->k != k ){
    c = c->next;
  }
  return c;
}
 
void init(){
  NIL = malloc(sizeof(struct node));
  NIL->next = NIL;
  NIL->prev = NIL;
}
 
void printList(){
  NodePointer c;
  c = NIL->next;
  int isf = 1;
  while(1){
    if ( c == NIL ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", c->k);
    c = c->next;
    isf = 0;
  }
  printf("\n");
}
 