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

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

Node *nil;

void insert(int key) {
  Node *n;
  n = (Node *)malloc(sizeof(Node));
  n->key = key;
  n->next = nil->next;
  nil->next = nil->next->prev = n;
  n->prev = nil;
}
void deleteNode(Node *n) {
  n->prev->next = n->next;
  n->next->prev = n->prev;
}

void delete(int key) {
  Node *n;
  for (n = nil->next; n != nil; n = n->next) {
    if (n->key == key) {
      deleteNode(n);
      return;
    }
  }
}

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

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



int main() {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
  int i, key, N;
  char command[30] = {' '};

  scanf("%d", &N);
  for (i = 0; i < N; i++) {
    command[6] = ' ';
    scanf(" %s", command);
    switch(command[0]) {
    case 'i':
      scanf(" %d", &key);
      insert(key);
      break;
    default :
      switch(command[6]) {
      case 'F':
        deleteFirst();
        break;
      case 'L':
        deleteLast();
        break;
      default:
        scanf(" %d", &key);
        delete(key);
        break;
      }
    }
  }

  Node *node;
  for (node = nil->next;; node = node->next) {
    if (node->next == nil) {
      printf("%d\n", node->key);
      break;
    }
    printf("%d ", node->key);
  }
  return 0;
}

