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

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

typedef struct node * NodePointer;

NodePointer nil;
/////////////////////////
void insert(int a){
  NodePointer n;
  n=malloc(sizeof(struct node));
  n->key=a;
  n->next=nil->next;
  nil->next->prev=n;
  n->prev=nil;
  nil->next=n;
}
/////////////////////////
void delete(int a){
  NodePointer n;
  for(n=nil->next;n!=nil;n=n->next){
    if(n->key==a)break;
  }
  n->prev->next=n->next;
  n->next->prev=n->prev;
  free(n);  
}
/////////////////////////
void deleteFirst(void){
  NodePointer n;
  n=nil->next;
  nil->next=n->next;
  n->next->prev=nil;
  free(n);
}
void deleteLast(void){
  NodePointer n;
  n=nil->prev;
  n->prev->next=nil;
  nil->prev=n->prev;
  free(n);
}
void init(void){
  nil=malloc(sizeof(struct node));
  nil->next=nil;
  nil->prev=nil;
}
int main(void){
  int i,n,key;
  char com[12];
  NodePointer k;
  scanf("%d", &n);
  init();

  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);

    if ( com[0] == 'i' ) {
      insert(key);

    } else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) {
	  deleteFirst();
	} else if ( com[6] == 'L' ) {
	  deleteLast();
	}
      } else {
	delete(key);
      }
    }

  }
  for(k=nil->next,i=0;k!=nil;k=k->next,i++){
    if(i!=0)printf(" %d",k->key);
    else printf("%d",k->key);
  }
  printf("\n");
  return 0;
}