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

struct node{
unsigned int key;
struct node *next;
struct node *prev;
};

typedef struct node *NodePointer;
NodePointer nil;
NodePointer listSearch(int key){
NodePointer x=nil->next;
while(x->key!=key){
  if(x==nil)break;
  x=x->next;
  }
  return x;
  }

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

void printList(){
  NodePointer np=nil->next;
  int s=1;
  while(1){
    if(np==nil){
      break;
    }
    if(s==0){
      printf(" ");
    }
    printf("%d",np->key);
    np=np->next;
    s=0;
  }
  printf("\n");
  }

void deleteNode(NodePointer np){
  np->prev->next=np->next;
  np->next->prev=np->prev;
  free(np);
  }

void deleteFirst(){
  NodePointer np=nil->next;
  if(np==nil)return;
  deleteNode(np);
  }

void deleteLast(){
  NodePointer x=nil->prev;
  if(x==nil)return;
  deleteNode(x);
  }

void delete(int key){
  NodePointer x;
  x=listSearch(key);
  if(x==nil)return;
  deleteNode(x);
  }

void insert(int key){
  NodePointer np;
  np=malloc(sizeof(struct node));
  np->key=key;
  np->next=nil->next;
  np->prev=nil;
  nil->next=np;
  np->next->prev=np;
  }

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

