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

long A[1000000];
long a=1000000,b=999999;

void insert(long n){
  A[--a] = n;
  return;
}
void deleteFirst(){
  if(a>b) return;
  a++;
  while(A[a] <0) a++;
  return;
}
void deleteLast(){
  if(a>b) return;
  b--;
  while(A[b] <0) b--;
  return;
}
void delete(long n){
  long i;
  if(a>b) return;
  else if(A[a]==n) {deleteFirst();return;}
  i=a+1;
  while(i<b){
    if(A[i]==n){
      A[i]=-1;
      return;
    }
    i++;
  }
  if(A[b]==n) {deleteLast(); return;}
  return;
}
void printQueue(){
  int i;
  if(a>b);
  else if(a==b)
    printf("%ld\n", A[a]);
  else {
    for (i=a; i<b; i++)
      if(A[i]>=0) printf("%ld ",A[i]);
    printf("%ld\n", A[b]);
  }
  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;
}

