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

typedef struct Node
{
  int key;
  struct Node *prev,*next;
}Node;

Node *nill;

void init()
{
  nill = (Node *)malloc(sizeof(Node));
  nill->next = nill;
  nill->prev = nill;
}

void insert(int key)
{
  Node *p = (Node *)malloc(sizeof(Node));

  p->key = key;

  p->next = nill->next;
  nill->next->prev = p;
  nill->next = p;
  p->prev = nill;
}

Node* listserch(int key)
{
  Node *cur = nill->next;

  while(cur != nill && cur->key != key)
  {
    cur = cur->next;
  }

  return cur;
}

void printList()
{
  Node *cur = nill->next;
  int isf = 0;

  while(1)
  {
    if(cur == nill) break;
    if(isf++ > 0) printf(" ");
    printf("%d",cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t)
{
  if(t == nill) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst()
{
  deleteNode(nill->next);
}

void deleteLast()
{
  deleteNode(nill->prev);
}

void deleteKey(int key)
{
  deleteNode(listserch(key));
}

int main()
{
  int key,n,i,nd = 0;
  char com[20];

  scanf("%d",&n);
  init();
  for(i = 0;i < n;i++)
  {
    scanf("%s%d",com,&key);
    if(com[0] == 'i') insert(key);
    else if(com[0] == 'd')
    {
      if(strlen(com) > 6)
      {
        if(com[6] == 'F') deleteFirst();
        else if(com[6] == 'L') deleteLast();
      }
      else deleteKey(key);nd++;
    }
  }
  printList();

  return 0;
}

