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

#define SIZE 100000

struct List{
  int key; 
  struct List *next;
  struct List *back;
};

struct List *list; //??????

void init(){
  list = (struct List*)malloc(sizeof(struct List));
  list->next = list;
  list->back = list;
}

void insert(int x){
  struct List *new;
  struct List *next;
  struct List *back;
  new = (struct List*)malloc(sizeof(struct List));
  new->key = x;
  new->next = list;
  back = list;
  for(next=list->next; next!=list; next=next->next){
    back = next;
  }
  new->back = back;
  back->next = new;
  next->back = new;

  //printf("insert %d\n",new->key);
}

void show(){
  int space=0;
  struct List *l;
  l = list->next;
  while(1){
    if(space!=0) printf(" ");
    space++;
     printf("%d",l->key);
    if(l->next == list) break;
    l = l->next;
  }
  printf("\n");
}

struct List* search(int x){ //?????????????????????????????????key?????¢???
  struct List *l;
  l = list;
  while(1){
    if(l->key == x){
      // printf("search %d\n",x);
      break;
    }
    if(l->next == list){
      x = -1;
      break;
    }
    l = l->next;
  }
  if(x!=-1) return l;
  else return list;
}

void deleteList(struct List *l){
  if(l==list) return;
  l->back->next = l->next;
  l->next->back = l->back;
}

void delete(int x){
  deleteList(search(x));
  //printf("delete %d\n",x);
}

void deleteFirst(void){
  list->next->next->back = list;
  list->next = list->next->next;
}

void deleteLast(void){
  struct List *l;
  l = list;
  while(l->next!=list){
    l = l->next;
  }
  l->back->next = list;
}


int main(void){
  int n;
  int i;
  char command[10];
  int x;

  init();
 
  scanf("%d", &n);
  
  for(i=0; i<n; i++){
    scanf("%s",command);
    if(command[6]!='F' && command[6]!='L')
      scanf("%d",&x);
    //printf("%s\n%d\n", command, x);
    if(command[0]=='i'){
      insert(x);
    }else if(command[6]=='F'){ // deleteFirst
      deleteFirst();
    }else if(command[0]=='L'){ //deleteLast
      deleteLast();
    }else{ //delete
      delete(x);
    }
  }

  show();


  return 0;
}