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

struct node{

  unsigned int key;
  struct node *next;
  struct node *prev;

};

typedef struct node *Pointer;

Pointer nil;

void in()
{
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}
Pointer listSearch(int key)
{
  Pointer n;

  for( n=nil->next; n != nil; n=n->next )
    {
      if( n->key == key ) return n;
    }
  return nil;
}

void printList()
{
  Pointer c = nil->next;
  
  int i = 1;

  while(1)
    {
      if( c == nil ) break;
      if( i == 0 ) printf(" ");
      printf("%d", c->key);
      c = c->next;
      i = 0;
    }
  printf("\n");
}


void deleteNode(Pointer t)
{
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}


void deleteFirst()
{
  Pointer a = nil->next;
  
  if( a == nil ) return;
  deleteNode(a);
}


void deleteLast()
{
  Pointer a = nil->prev;

  if( a == nil ) return;
  deleteNode(a);
 
}


void delete(int key)
{
  Pointer x;

  if( (x = listSearch(key)) == nil ) return;
  
  x->prev->next = x->next;
  
  x->next->prev = x->prev;


  free(x);

  
}

void insert(int key)
{
  Pointer x;
  
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main()
{
  int p = 0, d = 0;
  int key, n, i,size = 0;
  char o[20];

  
 

  scanf("%d", &n);
  in();

  for( i=0; i<n; i++ )
    {
      scanf("%s%d", o, &key);
     
      if( strcmp(o,"insert")==0)
	{
	  insert(key);
	  p++;
	  size++;
	}

       if(strcmp(o,"delete")==0)
	{
	  delete(key);
	  d++;
	   size--;
	}

  if(strcmp(o,"deleteFirst")==0){
    deleteFirst();
    size--;
  }
  if(strcmp(o,"deleteLast")==0){
    deleteLast();
    size--;
  }
}

printList();

return 0;
}

  


