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

struct node{
  int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}




void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  /* your code */
  t->next->prev = t->prev;
  t->prev->next = t->next;
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t != nil ) deleteNode(t);
}

void deleteLast(){
  NodePointer t = nil->prev;
  /* your code */
  if(t!=nil)deleteNode(t);

}

void delete(int key){
  /* your code */
  NodePointer del = nil->next;
  while(1){
    if(del->key == key){
      deleteNode(del);
      break;
    }
    del = del->next;
    if(del == nil->next)return;
  }
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  x->prev = nil;
  x->next = nil->next;
  nil->next->prev =x;
  nil->next = x;
  /* 

   your code 


  */

}

int main(){
  int key, n, i;
  char com[20];

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

  printList();
  return 0;
}

