#include<stdio.h>
#define MAX 2000000

void Insert(int);
void Delete(int);
void DeleteFirst(void);
void DeleteLast(void);

int S[MAX],count;
int main()
{
  int i,n,a1,a2;
  char order[12];

  scanf("%d",&n);
  for(i = 0;i < n;i++){
    S[i] = 0;
  }
  for(i = 0;i < n;i++){
    scanf("%s",order);
      if(order[0] == 'i'){
      scanf("%d",&a1);
      Insert(a1);
      count++;
    }
    else if(order[0] == 'd' && order[6] == 'L'){
      DeleteLast();
      }
    else if(order[0] == 'd' && order[6] == 'F'){
      DeleteFirst();
    }
    else {
      scanf("%d",&a2);
      Delete(a2);
    }
  }
  for(i = n;i >= 0;i--){
      if(S[i] != -1 && S[i] != 0)printf("%d ",S[i]);
  }

  printf("\n");
  return 0;
}
void Insert(int a)
{
  S[count] = a;
}

void Delete(int a)
{
  int i;
  for(i = 0;i < count;i++){
    if(S[i] == a) S[i] = -1;
  }
}

void DeleteFirst()
{
  int i;
  for(i = 0;i < count;i++){
    if(S[i] != -1){
      S[i] = -1;
      break;
    }
  }
}

void DeleteLast()
{
  int i;
  for(i = count -1;i >= 0;){
    if(S[i] != -1){
      S[i] = -1;
      break;
    }
  }
}