#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 2000000

typedef struct Node{
  struct Node *prev,*next;
   int data;
}node;


node *null;
void init(void);
void Insert(int);
node *listSearch(int);
void delete(node *);
void deleteFirst(void);
void deleteLast(void);
void listprint(void);

main(){
  int i,j,a,b[N];
  char *c;
  node *d;
  char e[] = "insert";
  char f[] = "delete";
  char g[] = "deleteFirst";
  char h[] = "deleteLast";

  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%s%d",c,&b[i]);
    if(strcmp(c,e)==0) Insert(b[i]);
    if(strcmp(c,f)==0) {
     
      delete(listSearch(b[i]));
    }
    if(strcmp(c,g)==0) deleteFirst();
    if(strcmp(c,h)==0) deleteLast();
      }

  listprint();
      return 0;
  }


void init(){
  null = (node *)malloc(sizeof(node));
  null->next = NULL;
  null->prev = NULL;
}



void Insert(int key){
  node *x = (node *)malloc(sizeof(node));
  x->data = key;
  x->next = null->next;
  null->next->prev = x;
  null->next = x;
  x->prev = null;
  free(x);
}

node *listSearch(int key){
  node *a;
  a = null->next;
  while(a!=NULL && a->data!=key){
    a = a->next;
  }
  return a;
}

void delete(node *a){
  if(a == NULL)return;
  a->prev->next = a->next;
  a->next->prev = a->prev;
}

void deleteFirst (){
  delete(null->next);
}

void deleteLast(){
  delete(null->prev);
}

void listprint(){
  node *n;
  for(n=null->next;n!=NULL;n=n->next){
    printf("%d ",n->data);
  }
}