#include<stdio.h>
  
 int main()
{
  int a,b;

    int i,j,y = 0;

int x, w, z;

  scanf("%d",&a);

  int ar1[a];
  char ar2[12];
 
  for(i = 0;i < a;i++){
    scanf("%s %d",ar2,&b);
 
    if(ar2[0] == 'i'){
      ar1[i] = b;
    }
 
    else if(ar2[6] == 'F'){
      i -= 2;
      a -= 2;
    }
 
    else if(ar2[6]=='L'){
      i--;
      a--;
      y++;
    }
 
    else{
      i--;
      a--;
      x = 0;
      for(j = i; j >= 0;j--){
 
	if(x > 0)break;
 
	if(b == ar1[j]){
	  z = 0;
	  w = i - j;
	  x++;
	  while(w != z++)ar1[j + z - 1] = ar1[j + 1 + z - 1];
	  i--;
	  a--;
	}
      }
    }
  }
  for(i = 0;i < a - y;i++){
    if(i == a - y - 1)
      printf("%d\n",ar1[a - 1 - i]);
    else printf("%d ",ar1[a - 1 - i]);
  }
  return 0;
}

