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

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

typedef struct node *nodepointer;
nodepointer set;

void insert(int);
void delete(int);
nodepointer nodesearch(int);
void deleteFirst(void);
void deleteLast(void);
void nodedelete(nodepointer);
void initialize(void);
void nodeprint(void);
int main(){

  int count; //命令回数
  char command[20];//命令
  int number;//数字
  int i=0;//ループカウンタ
  int j=1;
  nodepointer setup;

  
  
  scanf("%d",&count);
  initialize();
  while(i < count){
    scanf("%s%d",command,&number);
    i++;
    //命令の識別
    if(command[0]=='i') insert(number);
    else if(command[0]=='d'){
      if(strlen(command) > 6){
	if(command[6]=='F') deleteFirst();
	else if(command[6]=='L') deleteLast();
      }	
      else delete(number);
    }
  }
  nodeprint();
  return 0;
}

void nodeprint(){
  nodepointer setup = set->next;
  int count=1;
  while(1){
    if(setup==set)break;
    if(count==0)printf(" ");
    printf("%d",setup->key);
    setup = setup->next;
    count = 0;
  }
  printf("\n");
}
void initialize(){
  set = malloc(sizeof(struct node));
  set->next = set;
  set->prev = set;
}

void insert(int num){//格納
  nodepointer setup;
  setup = malloc(sizeof(struct node));
  setup->key = num;
  //setとnextの間にsetupを入れる
  setup->next = set->next;
  set->next->prev = setup;
  set->next = setup;
  setup->prev = set;
}
void delete(int num){
  nodepointer setup;
  setup = nodesearch(num);//検索

  if(setup != NULL){//nodeの中に発見
    nodedelete(setup);
    }
}

nodepointer nodesearch(int num){
  nodepointer setup = set->next;
  //検索
  while(setup != set && num != setup->key){
    setup = setup->next;
  }
  if(setup == set) return NULL;
  return setup;
}

void deleteFirst(){
  nodepointer setup = set->next;
  if(setup == set) return;
  nodedelete(setup);
}

void deleteLast(){
  nodepointer setup = set->prev;
  if(setup == set) return;
  nodedelete(setup);
}

void nodedelete(nodepointer setup){
  setup->next->prev = setup->prev;//間を削除
  setup->prev->next = setup->next;
  free(setup);
}