#include<stdio.h>
  
int main(){
  int r,w,i,j,y=0,f,g,h;
  scanf("%d",&r);
  int a[r];
  char b[12];
 
  for(i=0;i<r;i++){
    scanf("%s %d",b,&w);
 
    if(b[0]=='i'){
      a[i]=w;
    }
 
    else if(b[6]=='F'){
      i-=2;r-=2;
    }
 
    else if(b[6]=='L'){
      i--;r--;y++;
    }
 
    else{
      i--;r--;
      f=0;
      for(j=i;j>=0;j--){
 
    if(f>0)break;
 
    if(w==a[j]){
      h=0;
      g=i-j;
      f++;
      while(g!=h++)a[j+h-1]=a[j+1+h-1];
      i--;r--;
    }
      }
    }
  }
  for(i=0;i<r-y;i++){
    if(i==r-y-1)printf("%d\n",a[r-1-i]);
    else printf("%d ",a[r-1-i]);
  }
  return 0;
}