#include<stdio.h>
#include<string.h>
#include<stdlib.h>
typedef struct Node{
  int key;
 struct  Node *next,*prev;
}Node;
Node *nil;

Node* listSearch(int key){
  Node *cur=nil->next;//?????????????????????
  while(cur!=nil&& cur->key!=key){//????????????????????§
    cur= cur->next;
  }
  return cur;
}
void init(){
  nil=(Node *)malloc(sizeof(Node));
  nil->next=nil;
  nil->prev=nil;
}
void deleteNode(Node *p){
  if(p==nil)return;
  p->prev->next=p->next;
  p->next->prev=p->prev;
  free(p);
}
void deleteLast(){
  deleteNode(nil->prev);
}
void deleteFirst(){
  deleteNode(nil->next);
}
void deleteKey(int key){
  deleteNode(listSearch(key));
}
void printList(){
  Node *cur=nil->next;
  int i;
  for(i=0;cur!=nil;cur=cur->next,i++){
    if(i)printf(" ");
    printf("%d",cur->key);
}
  printf("\n");
}

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;
}
int main(){
  int n,i,key;
  char command[20];
  scanf("%d",&n);
  init();////
  for(i=0;i<n;i++){
    scanf("%s %d",command,&key);
    if(!strcmp(command,"insert"))insert(key);//if(i) i!=0
    else if(!strcmp(command,"deleteFirst"))deleteFirst();
    else if(!strcmp(command,"deleteLast"))deleteLast();
    else deleteKey(key);
  }
  printList();

  return 0;
}