#include <stdio.h>
#include <stdlib.h>
#define LEN 100005

void initialize(void);
int isEmpty(void);
int isFull(void);
void enqueue(int);
void dequeue(void);

void insert(int);
void delete(int);
void deleteFirst(void);
void deleteLast(void);

int Q[LEN+1];
int head, tail, n;

int main()
{
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  initialize();

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'd' ){
      if( com[6] == 'F') deleteFirst();
      else if( com[6] == 'L') deleteLast();
      else {
	scanf("%d", &x);
	delete(x);
      }
    }
  }

  for(i = tail;i >= head; i--){
    if(Q[i] != 0) printf("%d ",Q[i]);
  }
  printf("\n");

  return 0;
}

void insert(int x) {
  enqueue(x);
}

void deleteFirst(void){
  Q[head] = 0;
  head++;
}

void deleteLast(void){
  Q[tail] = 0;
  tail--;
}

void delete(int x){
  int i,j;

  for(i = 0;(head + i) <= tail;i++){
    if(Q[head+i] == x){
      for(j = 0;(head + i + j) <= tail;j++){
	Q[head + i + j] = Q[head + i + j + 1];
      }
    }
  }

}

void enqueue(int x){
  if(isFull() == 1){
    fprintf(stderr,"オーバーフロー\n");
    exit(1);
  }

  Q[tail] = x;

  if((tail + 1) == (LEN+1)) tail = 0;
  else tail++;
}

void dequeue(void){
  int x;
  if(isEmpty() == 1){
    fprintf(stderr,"アンダーフロー\n");
    exit(1);
  }
   
  x = Q[head];

  if((head + 1) == (LEN+1)) head = 0;

  else head++;

}

int isEmpty(void)
{
  if(head == tail) return 1;
  return 0;
}

int isFull(void)
{
  if(head == (tail + 1) % (LEN+1)) return 1;
  return 0;
}

void initialize(void)
{
  head  = 0;
  tail  = 0;
}