#include<stdio.h>
#include<string.h>
main(){
  int n,i,j,g,head=0,key,tail,list[100000];
  char comad[10];
  scanf("%d",&g);
  tail = 1;
  for(n=0;n<g;n++){
    scanf("%s",comad);
    scanf("%d",&key);

    if(strcmp(comad,"insert")==0){
    head++;
    list[head]=key;
      }
    else if(strcmp(comad,"delete")==0){
    for(i=head;i>tail;i--){
      if(list[i]==key)break;}
    for(j=i;j>tail;j--){
      list[i]=list[i-1];
}
    tail++;
  }
    else if(strcmp(comad,"deleteFirst")==0){
    head--;
  }
    else if(strcmp(comad,"deleteLast")==0){
    tail++;
  }
  }
    for(i=head;i>tail;i--){
    printf("%d",list[i]);
    if(i>tail+1)printf(" ");
  }
   printf("?\n");
  return 0;
}