#include<stdio.h>
 
struct{
    int key;
    struct node *next;
    struct node *prev;
    } typedef Node pointer;

NodePointer finditem(int);
void print(void);
NodePointer make_1node(int,NodePointer);
void deleteFirst(void);
void deleteLast(void);
void deleteNode(NodePointer);
NodePointer head;
 
int main(){
    int key, n, i;
  int size = 0;
  char order[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", order, &key);
    if ( order[0] == 'i' ) {insert(key); np++; size++;}
    else if ( order[0] == 'd' ) {
      if (strlen(order) > 6){
    if ( order[6] == 'F' ) deleteFirst();
    else if ( order[6] == 'L' ) deleteLast();
      } else {
    delete(key); nd++;
      }
      size--;
    }
  }
    
  print();
  return 0;
}
 
NodePointer finditem(int key){
  NodePointer x;
  x = head->next;
  while(x != head && x->key != key){
    x = x->next;
  }
  return x;
}
 
void insert(int key){
  NodePointer y;
  y = malloc(sizeof(struct node));
  y->key = key;
  y->next = head->next;
  head->next->prev = y;
  head->next = y;
  y->prev = head;   
}
 
void print(){
  NodePointer z = head->next;
  int flag = 1;
  while(1){
    if ( z == head ) break;
    if ( flag == 0)  printf(" ");
    printf("%d", z->key);
    z = z->next;
    flag = 0;
  }
  printf("\n");
}
 
void deleteNode(NodePointer del){
  del->prev->next = del->next;
  del->next->prev = del->prev;
  free(del);
}
  
void deleteFirst(){
  NodePointer del_f = head->next;
  if ( del_f == head ) return;
  deleteNode(del_f);
}
  
void deleteLast(){
  NodePointer del_l = head->prev;
  if ( del_l == head ) return;
  deleteNode(del_l);
}
  
void delete(int key){
  NodePointer del;
  del = finditem(key);
  if(del == head) return;
    
  deleteNode(del);
    
}
void init(){
  head = malloc(sizeof(struct node));
  head->next = head;
  head->prev = head;
}