#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef struct tagNode{
  int x;
  struct tagNode* prev;
  struct tagNode* next;
}node;
node* head;
node* tail;
node* makenode(int x){
  node* new_node;
  new_node=(node*)malloc(sizeof(node));
  new_node->x=x;
  new_node->prev=NULL;
  new_node->next=NULL;
  return new_node;
}
void insert(int x){
  node* add;
  add=makenode(x);
  add->next=head->next;
  add->prev=head;
  head->next->prev=add;
  head->next=add;
}
void delnode(node* del){
  del->prev->next=del->next;
  del->next->prev=del->prev;
  free(del);
}
void search(int x){
  node* list;
  for(list=head->next;list!=head;list=list->next){
    if(list->x==x){
      delnode(list);
      break;
    }
  }
}
void deleteFirst(){
  delnode(head->next);
}
void deleteLast(){
  delnode(tail->prev);
}
void Display(){
  node* list;
  int flag=0;
  for(list=head->next;list!=tail;list=list->next){
    if(flag!=0) printf(" ");
    printf("%d",list->x);
    flag=1;
  }
  printf("\n");
}
int main(){
  int i,n,data;
  char str[256];
  head=makenode(-1);
  tail=makenode(-1);
  head->next=head->prev=tail;
  tail->prev=tail->next=head;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",str);
    if(strcmp(str,"insert")==0){
      scanf("%d",&data);
      insert(data);
    }
    else if(strcmp(str,"delete")==0){
      scanf("%d",&data);
      search(data);
    }
    else if(strcmp(str,"deleteFirst")==0){
      deleteFirst();
    }
    else if(strcmp(str,"deleteLast")==0){
      deleteLast();
    }
  }
  Display();
  return 0;
}