#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
typedef struct node{
  int key;
  struct node* next;
  struct node* prev;
}Node;
 
Node *NIL;
void init(void);
void printList(void);
Node* listSearch(int);
void insert(int);
void deleteNode(Node *);
void deleteLast(void);
void deleteKey(int);

 int main(){
  int key,n,i,size=0,np=0,nd=0;
  char com[20];
 
  scanf("%d",&n);
  init();
  for(i = 0;i < n;i++){
    scanf("%s%d",com,&key);
    if(com[0] == 'i'){
      insert(key);
      np++;
      size++;
    }
    else if(com[0] == 'd'){
      if(strlen(com) > 6){
    if(com[6] == 'F') deleteFirst();
    else if(com[6] == 'L') deleteLast();
      }
      else{
    deleteKey(key);
    nd++;
      }
      size--;
    }
  }
  printList();
 
  return 0;
}

void init(){
  NIL = (Node*)malloc(sizeof(Node));
  NIL -> next = NIL;
 NIL  -> prev = NIL;
}
 
void printList(){
  Node *cur = NIL -> next;
  int isf = 0;
  while(1){
    if(cur == NIL) break;
    if(isf++ > 0) printf(" ");
    printf("%d",cur -> key);
    cur = cur -> next;
  }
  printf("\n");
}
 
Node* listSearch(int key){
  Node *cur = nil -> next;
  while(cur != NIL && cur -> key != key) cur = cur -> next;
  return cur;
}
 
void insert(int key){
  Node *x = (Node*)malloc(sizeof(Node));
  x -> key = key;
  x -> next = nil -> next;
  NIL -> next -> prev = x;
  NIL -> next = x;
  x -> prev = NIL;
}
 
void deleteNode(Node *t){
  if(t == NIL) return ;
  t -> prev -> next = t -> next;
  t -> next -> prev = t -> prev;
  free(t);
}
 
void deleteFirst(){
  deleteNode(NIL -> next);
}
 
void deleteLast(){
  deleteNode(NIL -> prev);
}
 
void deleteKey(int key){
  deleteNode(listSearch(key));
}
 