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

#define N 15

struct Link{
  int linkkey;
  struct Link *Next;
  struct Link *Before;
};

typedef struct Link * LinkSearch;

LinkSearch Target;

void LinkIn(int );
void DelFast();
void DelLast();
void Dellinkkey(int );
void DelLink(LinkSearch );
LinkSearch Search(int );


int main(){
  LinkSearch link;
  int count=0;
  int loop,linknum;
  char order[N];
  int i;

  Target=malloc(sizeof(struct Link));
  Target->Next=Target;
  Target->Before=Target;

  scanf("%d",&loop);

  for(i=0;i<loop;i++){
    scanf("%s",order);
    
    if(order[0]=='i'){
      scanf("%d",&linknum);
      LinkIn(linknum);
    }
    
    else if(order[0]=='d'){
      if(strlen(order)==6){
	scanf("%d",&linknum);
	Dellinkkey(linknum);
      }
      
      else if(strlen(order)>6){
	
	if(order[6]=='F'){
	DelFast();
	}

	else if(order[6]=='L'){
	  DelLast();
	}
	
      }
    }
  }
  
  link=Target->Next;
  
  while(link!=Target){
   
    if(count>=1){
      printf(" ");
    }

    printf("%d",link->linkkey);
    link=link->Next;
    count++;
  }

  printf("\n");
  
  
  return 0;
}

void LinkIn(int number){
  LinkSearch insert;

  insert=malloc(sizeof(struct Link));
  
  insert->linkkey=number;
  
  insert->Next=Target->Next;
  
  Target->Next->Before=insert;
  
  Target->Next=insert;
  
  insert->Before=Target;
  
}

void DelFast(){
  LinkSearch First;

  First=Target->Next;
  
  if(First==Target){
    return;
  }
  
  DelLink(First);
}

void DelLast(){
  LinkSearch Last;

  Last=Target->Before;
  
  if(Last==Target){
    return;
  }
  
  DelLink(Last);
}

void Dellinkkey(int number){
  
  DelLink(Search(number));
  
}

void DelLink(LinkSearch Erase){

  if(Erase==Target){
    return;
  }

  Erase->Before->Next=Erase->Next;
  
  Erase->Next->Before=Erase->Before;
  
  free(Erase);
  
}

LinkSearch Search(int linknum){
  LinkSearch Sear;

  Sear=Target->Next;

  while((Sear!=Target) && (Sear->linkkey!=linknum)){
    Sear=Sear->Next;
  }

  return Sear;
}



