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

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

typedef struct node * NodePointer;

void insert(int);
NodePointer listSearch(int);
NodePointer make1node();
void deleteNode(NodePointer);
void deleteFirst();
void deleteLast();
void delete(int);

void listPrint();

NodePointer nil;

int main(){
  int n, i, key;
  char order[15];

  nil=make1node(); //二分木だから必要

  scanf("%d", &n);

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

  return 0;
}

void insert(int key){
  
  NodePointer p;

  p=(NodePointer)malloc(sizeof(struct node));

  p->key=key;
  p->next=nil->next;
  nil->next->prev=p;
  nil->next=p;
  p->prev=nil;
}

NodePointer listSearch(int key){

  NodePointer n;

  for(n=nil->next; n!=nil; n=n->next){
    if(n->key == key) return n;
  }
  return NULL;
}

NodePointer make1node(){

  NodePointer p;

  p=(NodePointer)malloc(sizeof(struct node));

  p->next=p;
  p->prev=p;

  return p;
}
void deleteNode(NodePointer p){

  if(p!=nil){
    p->prev->next=p->next;
    p->next->prev=p->prev;
    free(p);
  }
}

void deleteFirst(){

  deleteNode(nil->next);
}

void deleteLast(){

  deleteNode(nil->prev);
}
  
void delete(int key){
  
  NodePointer p;

  p=listSearch(key);

  if(p != NULL) deleteNode(p);

}

void listPrint(){

  NodePointer cur;
  int isf=1;

  cur=nil->next;

  while(1){

    if(cur == nil) break;
    if(isf == 0) printf(" ");

    printf("%d", cur->key);

    cur=cur->next;
    isf=0;
  }
  printf("\n");
}

