#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct node{ 
  int key;
  struct node *next;
  struct node *prev;
};
typedef struct node * NodePointer;
NodePointer N;
NodePointer listSearch(int key);
void initialize();
void print();
void deleteNode(NodePointer a);
void deleteFirst();
void deleteLast();
void delete(int key);
void insert(int key);
int main(){ 
  int key;
  int size;
  int currentSize = 0; 
  char op[50]; 
  int np = 0, nd = 0;
  scanf("%d", &size); 
  initialize();
  for ( int i = 0; i < size; i++ ){
    scanf("%s%d", op, &key);
    if ( op[0] == 'i' ) {
      insert(key);
      np++;
      currentSize++;
    } 
    else if ( op[0] == 'd' ) 
    {
      if (strlen(op) > 6){
	if ( op[6] == 'F' )
            deleteFirst();
	else if ( op[6] == 'L' )
            deleteLast();
      }
      else { delete(key); nd++; 
      } 
      currentSize--; 
    }
  }
  print(); 
  return 0;
}
NodePointer listSearch(int key)
{
NodePointer i;
  for(i=N;i->next!=N;i=i->next)
  {
    if(i->next->key==key)
        return i->next;
  }
  return NULL;
} 
void initialize()
{
  N = malloc(sizeof(struct node));
  N->next = N; 
  N->prev = N;
}
void print()
{ 
  NodePointer cur = N->next;
  int isf = 1;
  while(1){
    if ( cur == N ) break;
    if ( isf == 0) printf(" "); 
    printf("%d", cur->key);
    cur = cur->next; isf = 0; 
  } 
  printf("\n");
}
void deleteNode(NodePointer a)
{
  a->next->prev=a->prev;
  a->prev->next=a->next;
  free(a);
}
void deleteFirst()
{ 
  NodePointer a = N->next;
  if ( a == N )
      return;
  deleteNode(a);
}
void deleteLast()
{
  NodePointer i;
  i=N->prev;
  deleteNode(i);
}
void delete(int key)
{
  NodePointer i; 
  i=listSearch(key);
  if(i!=NULL)
      deleteNode(i);
} 
void insert(int key)
{ 
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next=N->next;
  N->next->prev=x;
  N->next=x;
  x->prev=N;
}

