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

int main(void){
  int n,i,j,k=0,a,key[200000],r[200000];
  char com[20];
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%s",com);
    if(strcmp(com,"insert")==0){
      k++;
      scanf("%d",&a);
      key[k]=a;
    }
    else if(strcmp(com,"delete")==0){
      scanf("%d",&a);
      for(j=k;j>=1;j--){
	if(key[j]==a){
	  key[j]=-1;
	  break;
	}
      }
    }
    else if(strcmp(com,"deleteFirst")){
      for(j=k;j>=1;j--){
	if(key[j]!=-1){
	  key[j]=-1;
	  break;
	}
      }
    }
    else if(strcmp(com,"deleteLast")){
      for(j=1;j<=k;j++){
	if(key[j]!=-1){
	  key[j]=-1;
	  break;
	}
      }
    }
  }
  j=0;
  for(i=1;i<=k;i++){
    if(key[i]!=-1){
      j++;
      r[j]=key[i];
    }
  }
  for(i=j;i>=1;i--){
    printf("%d ",r[i]);
  }
  printf("\b\n");
  return 0;
}

