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

struct Node{
  struct Node *prev;
  struct Node *next;
  long key;
};

typedef struct Node * np;
np MN(long);
void IN(np);
void DN(np);
void FI(long);
np dummy;

int main(){
  long int val,i,n;
  char op[12];
  np roop;
  
  scanf("%ld",&n);
  dummy = MN(0);
  
  for(i=0;i<n;i++){
    scanf("%s",op);
    
    if(strcmp(op,"insert") == 0){
      scanf("%ld",&val);
      IN(MN(val));
    }
    else if(strcmp(op,"delete") == 0){
      scanf("%ld",&val);
      FI(val);
    }
    else if(strcmp(op,"deleteFirst") == 0){
      DN(dummy->next);
    }
    else if(strcmp(op,"deleteLast") == 0){
      DN(dummy->prev);
    }
  }

  for(roop=dummy->next;roop!=dummy;roop =roop->next){
    printf("%ld",roop->key);
    if(roop->next != dummy)printf(" ");
  }  
  printf("\n");

  return 0;
}

void FI(long value){
  np n;
  dummy->key = value;
  for(n = dummy->next;;n=n->next){
    if(n->key == value)break;
  }
  if(n != dummy)DN(n);
    
}

void DN(np th){
  th->prev->next = th->next;
  th->next->prev = th->prev;
  th->prev = th->next = th;
  free(th);
  //delete th;
}

void IN(np newn){
  newn->next = dummy->next;
  newn->next->prev = newn;
  dummy->next = newn;
  newn->prev = dummy;
}

np MN(long key){
  np not = (np)malloc(sizeof(struct Node));
  //n = new struct node();
  not->prev = not;
  not->next = not;
  not->key = key;
  return not;
} 

