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

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

typedef struct node *NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer cur=nil->next;
  
  while(cur!=nil && cur->key!=key){
    cur=cur->next;
  }

  return cur;
}

void init(){
  nil=malloc(sizeof(struct node));
  nil->next=nil;
  nil->prev=nil;
}

void printList(){
  NodePointer cur=nil->next;
  int a=0;

  while(1){
    if(cur==nil) break;
    if(a++>0) printf(" ");
    printf("%d",cur->key);
    cur=cur->next;
  }

  printf("\n");
}

void dNode(NodePointer t){
  
  if(t==nil) return;
  t->prev->next=t->next;
  t->next->prev=t->prev;
  free(t);
}

void dFirst(){
  NodePointer t=nil->next;

  if(t==nil) return;

  dNode(t);
}

void dLast(){
  dNode(nil->prev);
}

void delete(int key){
  dNode(listSearch(key));
}

void insert(int key){
  NodePointer x=malloc(sizeof(struct node));
  
  x->key=key;
  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;
}

int main(){
  int key,n,i,size=0,p=0,d=0;
  char com[20];

  scanf("%d",&n);

  init();

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

    if(com[0]=='i'){
      insert(key);
      p++;
      size++;
    }
    else if(com[0]=='d') {
      if(strlen(com)>6){
	if(com[6]=='F') dFirst();
	else if(com[6]=='L') dLast();
      }
      else{
	delete(key);
	d++;
      }
      size--;
    }
  }

  printList();

  return 0;
}
