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

typedef struct Node {
  int key;
  struct Node *prev, *next;
} Node;

Node *nil;

void init(){
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void insert(int key){
/*  printf("insert %d\n", key);*/
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  nil->next->prev = x;
  x->next = nil->next;
  nil->next = x;
  x->prev = nil;
}

void delete(int key){
/*  printf("delete %d\n", key); */
  Node *cur = nil->next;
  while(cur->key != key && cur != nil){
    cur = cur->next;
  }
  if(cur->key == key){
    cur->prev->next = cur->next;
    cur->next->prev = cur->prev;
    free(cur);
  }
}

void deleteFirst(){
  Node *tmp = nil->next;
  nil->next = tmp->next;
  tmp->next->prev = nil;
  free(tmp);
}

void deleteLast(){
  Node *tmp = nil->prev;
  tmp->prev->next = nil;
  nil->prev = tmp->prev;
  free(tmp);
}

void printList(){
  Node *cur = nil->next;
  int isf = 0;
  while(cur != nil){
    if(isf++ > 0)printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
  }
  printf("\n");
}

int main(){
  init();
  int n, key;
  char str[20];

  scanf("%d",&n);

  for(int i = 0; i < n; i++){
    scanf("%s%d", str, &key);
    if(str[0] == 'i'){
      insert(key);
    }else if(str[0] == 'd'){
      if(strlen(str) > 6){
        switch(str[6]){
          case 'F':
            deleteFirst();
            break;
          case 'L':
            deleteLast();
            break;
        }
      }else{
        delete(key);
      }
    }
  }
  printList();
  return 0;
}

