#include<stdio.h>
#include<string.h>
int first=0;
int last=0;
int a[2000100];
int main(void){
  int n;
  scanf("%d",&n);
  char x[10];
  int d,i;

  for(;n>0;n--){
    scanf("%s",x);
    if(strcmp(x,"insert")==0){
      scanf("%d",&d);
      a[first]=d;
      first++;
    }

    else if(strcmp(x,"delete")==0){
      scanf("%d",&d);
      for(i=first;i>=last;i--){
        if(a[i]==d){
          a[i]=-1;
          if(i==first-1)first--;
          if(i==last)last++;
          break;
        }
      }
    }

    else if(strcmp(x,"deleteLast")==0){
      last++;
    }

    else if(strcmp(x,"deleteFirst")==0){
      a[first-1]=-1;
      first--;
    }
  }

  int c=0;
  for(i=first-1;i>last;i--){
    if(a[i]!=-1){
      if(c==0){printf("%d",a[i]);}
      else {printf(" %d",a[i]);}
      c++;
    }
  }

  if(a[i]!=-1){
    if(c==0)printf("%d\n",a[i]);
    else printf(" %d\n",a[i]);
  }
  else printf("\n");

  return 0;
}

