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

#define prinf printf
#define SIZE 1000000
int main(){
  int n;
  char order[20];
  int key;
  int list[SIZE];
  int first=SIZE-1;
  int i,j;
  int flag=0;

  scanf("%d",&n);

  for(j=0;j<n;j++){
    scanf("%s ",order);
    if(strcmp(order,"insert")==0){
      scanf("%d",&key);
      list[first]=key;
      first--;
    }else if(strcmp(order,"delete")==0){
      scanf("%d",&key);
      for(i=first+1;i<SIZE;i++){
	if(list[i]==key){
	  list[i]=-1;
	  break;
	}
      }
    }else if(strcmp(order,"deleteFirst")==0){
      for(i=first+1;i<SIZE;i++){
	if(list[i]!=-1){
	  list[i]=-1;
	  break;
	}
      }
    }else if(strcmp(order,"deleteLast")==0){
      for(i=SIZE-1;i>first;i--){
	if(list[i]!=-1){
	  list[i]=-1;
	  break;
	}
      }
    }
  }

  for(i=first+1;i<SIZE;i++){
    if(list[i]!=-1){
      if(flag==0){
	printf("%d",list[i]);
	flag=1;
      }else{
	prinf(" %d",list[i]);
      }
    }
  }
  printf("\n");

  return 0;
}