#include<stdio.h>
#include<stdlib.h>
#include<string.h>
  
struct node{
  unsigned int key;
  struct node *n;
  struct node *p;
};
  
typedef struct node * NodePointer;
  
NodePointer nil;
  
NodePointer listSearch(int key){
  /* your code */
}
  
void init(){
  nil = malloc(sizeof(struct node));
  nil->n = nil;
  nil->p = nil;
}
  
void printList(){
  NodePointer cu = nil->n;
  int is = 1;
  while(1){
    if ( cu == nil ) break;
    if ( is == 0)  printf(" ");
    printf("%d", cu->key);
    cu = cu->n;
    is = 0;
  }
  printf("\n");
}
  
void deleteNode(NodePointer t){
  /* your code */
  t->p->n = t->n;
  t->n->p = t->p;
  
}
  
void deleteFirst(){
  NodePointer t = nil->n;
  if ( t == nil ) return;
  deleteNode(t);
}
  
void deleteLast(){
  /* your code */
  deleteNode(d);
}
  
void delete(int key){
  /* your code */
  NodePointer d;
  d=listSearch(key);
  deleteNode(d);
}
  
  
void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  
  /* your code */
  x->n = nil->n;
  nil->n->p = x;
  nil->n = x
  x->p = nil
    
  
  
}
  
int main(){
  int key, n, i;
  int size = 0;
  char co[20];
  int n_p = 0, n_d = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", co, &key);
    if ( co[0] == 'i' ) {insert(key); n_p++; size++;}
    else if ( co[0] == 'd' ) {
      if (strlen(co) > 6){
    if ( co[6] == 'F' ) deleteFirst();
    else if ( co[6] == 'L' ) deleteLast();
      } else {
    delete(key); n_d++;
      }
      size--;
    }
  }
  
  printList();
  return 0;
}