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

struct node{
  unsigned int key;
  struct node *prev;
  struct node *next;
};
typedef struct node *NodePointer;

NodePointer nil;

NodePointer search(int);
void insert(int);
void deleteKey(int);
void deleteFirst(void);
void deleteLast(void);
void deleteNode(NodePointer);
void printlist(void);
void init(void);

int main(){
  int n = 0, i = 0;
  char command[15];
  int val = 0;
  NodePointer now;
  init();
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%s%d",command,&val);
    if(command[0] == 'i'){
      insert(val);
    }
    else if(command[0] == 'd'){
      if(strlen(command) > 6){
	if(command[6] == 'F')deleteFirst();
	else if(command[6] == 'L')deleteLast();
      }
      else deleteKey(val);
    }
  }

  printlist();
  
  return 0;
}

NodePointer search(int k){
  NodePointer x;
  x = nil->next;
  while(x != nil && x->key != k){
    x = x->next;
  }
  return x;
}
void insert(int k){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = k;  
  x->next = nil->next;
  x->next->prev = x;
  nil->next = x;
  x->prev = nil;
  
}

void deleteKey(int k){
  deleteNode(search(k));
  /* NodePointer x;
  x = search(k);
  x->prev->next = x->next;
  x->next->prev = x->prev;
  free(x);*/
}

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

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

void deleteNode(NodePointer x){
  if(x == nil)return;
  x->prev->next = x->next;
  x->next->prev = x->prev;
  free(x);
}

void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
  deleteNode(nil->prev);
}

