#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct node{
  int key;
  struct node *next;
  struct node *prev;
};
typedef struct node *Node;
Node head;
void delete(Node);
int main(){
  int n,i,flag,key;
  char inst[12];
  Node index;
  scanf("%d",&n);
  head = (Node *)malloc(sizeof(Node));
  head->next = head;
  head->prev = head;
  for(i=0;i<n;i++){
    scanf("%s",inst);
    if( 'F' == inst[0] ){
      delete(head->next);
    }
    else if( 'L' == inst[6]){
      delete(head->prev);
    }
    else{
      scanf("%d",&key);
      if( 'i' == inst[0]){
	Node tmp;
	tmp = (Node *)malloc(sizeof(Node));
	tmp->key = key;
	tmp->next = head->next;
	head->next->prev = tmp;
	head->next = tmp;
	tmp->prev = head;
      }
      else{
	index = (Node *)malloc(sizeof(Node));
	index = head->next;
	while( index != head && index->key != key){
	  index = index->next;
	}
	if( index == head ){
	  continue;
	}
	delete(index);
      }
    }
  }
  index = head->next;
  flag = 0;
  while(index != head){
    if( flag > 0){
      printf(" ");
    }
    flag++;
    printf("%d",index->key);
    index = index->next;
  }
  printf("\n"); 
  return 0;
}
void delete(Node tmp){
  tmp->next->prev = tmp->prev;
  tmp->prev->next = tmp->next;
  free(tmp);
}