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

#define MAX 100000

typedef struct List{
  int key;
  struct List *next;
  struct List *prev;
}LIST;

LIST *list;

LIST* search(int key){
  LIST *x = list->next;
  while(x!=list && x->key!=key) x = x->next;
  return x;
}

void init(){
  list = (LIST *)malloc(sizeof(LIST));
  list->next = list;
  list->prev = list;
}

void print(){
  LIST *x = list->next;
  int i = 0;
  while(1){
    if(x == list) break;
    if(i++ > 0) printf(" ");
    printf("%d", x->key);
    x = x->next;
  }
  printf("\n");
}

void insert(int key){
  LIST *x = (LIST *)malloc(sizeof(LIST));
  x->key = key;
  x->next = list->next;
  list->next->prev = x;
  list->next = x;
  x->prev = list;
}

void deletenode(LIST *x){
  if(x == list) return;
  x->prev->next = x->next;
  x->next->prev = x->prev;
  free(x);
}

void deletekey(int key){ deletenode(search(key)); }

void deleteFirst(){ deletenode(list->next); }

void deleteLast(){ deletenode(list->prev); }

int main(){

  int key, n, i, size = 0, np = 0, nd = 0;
  char com[20];

  scanf("%d", &n);

  init();

  for(i = 0; i < n; i++){
    scanf("%s %d", com, &key);
    if(com[0] == 'i'){
      insert(key);
      np++;
      size++;
    }
    else if(com[0] == 'd'){
      if(strlen(com) > 6){
        if(com[6] == 'F') deleteFirst();
        else if(com[6] == 'L') deleteLast();
      }else {
        deletekey(key);
        nd++;
      }
      size--;
    }
  }

  print();

  return 0;
}