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

typedef struct node{
  int key;
  struct node *prev;
  struct node *next;
}Node, *NodePointer;



NodePointer nil;

void init(){
  nil = malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void insert(int k){
  NodePointer x = malloc(sizeof(Node));

  x->key = k;

  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

NodePointer listSearch(int key){
  NodePointer ser;
  ser = nil->next;
  while(ser != nil && ser->key != key){
    ser = ser->next;
  }
  return ser;
}

void deleteNode(NodePointer del){
  if(del == nil)return;

  del->prev->next = del->next;
  del->next->prev = del->prev;
  free(del);
}

void deleteKey(int key){
  deleteNode(listSearch(key));
}
void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void print(){
  NodePointer prt = nil->next;
  while(1){
    if(prt == nil)break;
    printf("%d",prt->key);
    if(prt->next != nil){printf(" ");}
    prt = prt->next;
  }
  
  printf("\n");
}

int main(){
  int n, k,m;
  char com[11];

  scanf("%d",&n);

  init();
  for(m=0;m<n;m++){
    scanf("%s%d",com,&k);

    if(com[0] == 'i'){
      insert(k);
    }else if(com[0] == 'd'){
      if(com[6] == 'F'){
        deleteFirst();
      }else if(com[6] == 'L'){
        deleteLast();
      }else{
        deleteKey(k);
      }
    }
    

  }
   print();
  return 0;
  
}

