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

typedef struct dlobj{
  struct dlobj *prev;
  struct dlobj *next;
  int key;
} dlobj;

typedef struct{
  dlobj *head;
} dlist;

dlist *createList(){
  dlist *L = malloc(sizeof(dlist));
  L->head = NULL;
}

void insert(dlist *L){
  int n;
  scanf("%d",&n);
  dlobj *p;
  p = malloc(sizeof(dlobj));
  p->key = n;
  p->next = L->head;
  if(L->head != NULL) L->head->prev = p;
  L->head = p;
  p->prev = NULL;
}

void delete(dlist *L){
  int n;
  scanf("%d",&n);
  dlobj *p;
  p = L->head;
  while(p->key != n && p != NULL){
    p = p->next;
  }
  if(p->key == n){
    if(p->prev !=NULL) p->prev->next = p->next;
    else L->head = p->next;
    if(p->next !=NULL) p->next->prev = p->prev;
  }
}

void deleteFirst(dlist *L){
  L->head = L->head->next;
  L->head->next->prev = NULL;
}

void deleteLast(dlist *L){
  dlobj *p,*q;
  p = L->head;
  while(p != NULL){
    q = p;
    p = p->next;
  }
  if(L->head !=q) q->prev->next = NULL;
  else L->head = NULL;
}

void print(dlist *L){
  dlobj *p;
  p = L->head;
  while(p != NULL){
    printf("%d ",p->key);
    p = p->next;
  }
  printf("\n");
}

int main(){
  int i,n;
  char str[20];
  dlist *L = createList();
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",str);
    if(strcmp(str,"insert")==0) insert(L);
    else if(strcmp(str,"delete")==0) delete(L);
    else if(strcmp(str,"deleteFirst")==0) deleteFirst(L);
    else if(strcmp(str,"deleteLast")==0) deleteLast(L);
  }
  print(L);
  free(L);
  return 0;
}