#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
#define MAX 100000
 
struct list{
  int key;
  struct list *next,*back;
};
 
struct list *nil;
 
struct list* search(int key){
  struct list *x = nil->next;
  while(x!=nil && x->key!=key) x = x->next;
  return x;
}
 
void init(){
  struct list *x = (struct list *)malloc(sizeof(struct list));
  x->next = x;
  x->back = x;
}
 
void print(){
  struct list *x = nil->next;
  while(1){
    if(x == nil) break;
    printf("%d ", x->key);
    x = x->next;
  }
  printf("\n");
}
 
void insert(int key){
  struct list *x = (struct list *)malloc(sizeof(struct list));
  x->key = key;
  x->next = nil->next;
  nil->next->back = x;
  nil->next = x;
  x->back = nil;
}
 
void delete(struct list *x){
  if(x ==nil) return;
  x->back->next = x->next;
  x->next->back = x->back;
  free(x);
}
 
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);
    }
    else if(com[0] == 'd'){
      if(strlen(com) > 6){
        if(com[6] == 'F') delete(nil->next);
        else if(com[6] == 'L') delete(nil->back);
      }else {
        delete(search(key));
      }
    }
  }
 
  print();
 
  return 0;
}