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

typedef struct a{
  int num;
  struct a *next,*prev;
}Node;

void insert(int n,Node* nil){
  Node* node = (Node*)malloc(sizeof(Node));
  node->num=n;
  nil->next->prev = node;
  node->next = nil->next;
  node->prev = nil;
  nil->next = node;
}

void delete(Node* node){
  node->next->prev = node->prev;
  node->prev->next = node->next;
  free(node);
}

void dsearch(Node* nil,int x){
  Node* node;
  for(node=nil->next;node!=nil;node = node->next){
    if(node->num==x){
      delete(node);
      break;
    }
  }
}

int main(void){
  int h,i,x;
  char str[16];
  Node *nil;
  Node *lac;
  nil = (Node*)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
  scanf("%d",&h);
  for(i=0;i<h;i++){
    scanf("%s",str);
    if(strcmp(str,"deleteFirst")==0){
      delete(nil->next);
    }else if(strcmp(str,"deleteLast")==0){
      delete(nil->prev);
    }else if(strcmp(str,"insert")==0){
      scanf("%d",&x);
      insert(x,nil);
    }else if(strcmp(str,"delete")==0){
      scanf("%d",&x);
      dsearch(nil,x);
    }
  }
  for(lac=nil->next;lac!=nil;lac=lac->next){
    printf("%d",lac->num);
    if(lac->next!=nil){
      printf(" ");
    }
  }
  printf("\n");
  return 0;
}


