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

long queue[1000000];
long qs=1000000,qe=999999;

void insert(long n){
  queue[--qs] = n;
  return;
}
void deleteFirst(){
  if(qs>qe) return;
  qs++;
  while(queue[qs] <0) qs++;
  return;
}
void deleteLast(){
  if(qs>qe) return;
  qe--;
  while(queue[qe] <0) qe--;
  return;
}
void delete(long n){
  long i;
  if(qs>qe) return;
  else if(queue[qs]==n) {deleteFirst();return;}
  i=qs+1;
  while(i<qe){
    if(queue[i]==n){
      queue[i]=-1;
      return;
    }
    i++;
  }
  if(queue[qe]==n) {deleteLast(); return;}
  return;
}
void printQueue(){
  int i;
  if(qs>qe);
  else if(qs==qe)
    printf("%ld\n", queue[qs]);
  else {
    for (i=qs; i<qe; i++)
      if(queue[i]>=0) printf("%ld ",queue[i]);
    printf("%ld\n", queue[qe]);
  }
  return;
}
int main(){
  long n,N; char c[12];
  scanf("%ld\n",&N);
  while(scanf("%s %ld\n",c,&n) != EOF){
    if(*c=='i')
      insert(n);
    else if(*(c+6)=='F')
      deleteFirst();
    else if(*(c+6)=='L')
      deleteLast();
    else
      delete(n);
  }
  printQueue();
  return 0;
}