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

void insert(int _value);
void delete(int _value);
void deleteFirst(void);
void deleteLast(void);

struct Node{

  struct Node* next;
  struct Node* prev;
  int value;

};

struct Node* head;
struct Node* tail;
main(){

  int i;
  int n;
  int tmpValue;
  char str[20];
  struct Node* node;

  head = (struct Node*)malloc(sizeof(struct Node));
  tail = (struct Node*)malloc(sizeof(struct Node));
  head->next = tail;
head->prev = tail;

  scanf("%d",&n);

  for(i=0; i<n; i++){
    scanf("%s",str);
    if(!strcmp(str,"insert")){
      scanf("%d",&tmpValue);
      insert(tmpValue);
    }else if(!strcmp(str,"deleteFirst")){
      deleteFirst();
    }else if(!strcmp(str,"deleteLast")){
      deleteLast();
    }else if(!strcmp(str,"delete")){
      scanf("%d",&tmpValue);
      delete(tmpValue);
    }
  }

  for(node=head->next; node != tail; node=node->next){
    printf("%d",node->value);
    if(node->next!=tail){
      printf(" ");
    }
  }
  printf("\n");

  return 0;

}

void insert(int _value){

  struct Node* newNode;
  struct Node* tmpNode;

  newNode = (struct Node*)malloc(sizeof(struct Node));

  tmpNode = head->next;
  if(tmpNode != NULL){
    tmpNode->prev = newNode;
  }
  head->next = newNode;
  newNode->next = tmpNode;
  newNode->prev = head;

  newNode->value = _value;

}

void delete(int _value){

  struct Node* node;
  struct Node* tmpNode;
  for(node=head->next; node != NULL; node=node->next){
    if(node->value == _value){
      tmpNode = node->prev;
      if(tmpNode != NULL){
	tmpNode->next = node->next;
      }
      if(node->next != NULL){
	node->next->prev = tmpNode;
      }
      break;
    }
  }

}

void deleteFirst(){

  struct Node* node;
  node=head->next;

  if(head != NULL){
    head->next= node->next;
  }
  if(node->next != NULL){
    node->next->prev = head;
  }
  free(node);

}

void deleteLast(){

  struct Node* tmpNode;

  tmpNode=tail->prev;
  tail->prev=tmpNode->prev;
  tmpNode->prev->next=tail;

  free(tmpNode);

}