#include <stdio.h>
#include <string.h>
#include <stdlib.h>
  
typedef struct Node* NodePointer;
  
typedef struct Node {
  int k;
  NodePointer next, p;
} Node;
  
NodePointer head, last;
  
NodePointer make_node(int k) {
  NodePointer tmp = malloc(sizeof(Node));
  tmp->next = tmp->p = NULL;
  tmp->k = k;
  return tmp;
}
  
void init() {
  head = malloc(sizeof(Node));
  last = malloc(sizeof(Node));
  head->next = last;
  last->pre = head;
}
  
void insert(NodePointer s, int k) {
  NodePointer node = make_node(k);
  NodePointer t = s->next;
  s->next = node;
  node->p = s;
  node->next = t;
  t->p = node;
}
  
void delete(NodePointer p) {
  NodePointer s = p->p;
  NodePointer t = p->next;
  s->next = t;
  t->p = s;
  free(p);
}
  
int main() {
  int N, num;
  char str[30];
  NodePointer p;
  init();
  scanf(" %d ", &N);
  while(N--) {
    scanf(" %s ", str);
    if(!strcmp(str,"insert")) {
      scanf(" %d ", &num);
      insert(head,num);
    } else if(!strcmp(str,"delete")) {
      scanf(" %d ", &num);
      for(p = head->next; p != last; p = p->next) {
        if(p->k == num) {
          delete(p);
          break;
        }
      }
    } else if(!strcmp(str,"deleteFirst")) {
      delete(head->next);
    } else if(!strcmp(str,"deleteLast")) {
      delete(last->p);
    }
  }
  
  for(p = head->next; p != last; p = p->next) {
    printf(p == head->next? "%d":" %d", p->k);
  }
  printf("\n");
  
  return 0;
}