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

typedef struct LLIST LList;
struct LLIST {
  LList *prev, *next;
  int v;
};

void add(LList *prev, LList *e) {
  e->next = prev->next;
  e->prev = prev;
  prev->next->prev = e;
  prev->next = e;
}

void removeElem(LList *e) {
  LList *prev = e->prev, *next = e->next;
  prev->next = next;
  next->prev = prev;
  free(e);
}

LList *findElem(LList *root, int v) {
  LList *p = root->next;
  while (p != root) {
    if (p->v == v) return p;
    p = p->next;
  }
  return p;
}

void printList(LList *root) {
  LList *p = root->next;
  while (p != root) {
    printf("%d", p->v);
    p = p->next;
    if (p != root) putchar(' ');
  }
  putchar('\n');
}

int main(int argc, char *argv[]) {
  int n;
  char s[16];
  scanf("%d", &n);
  LList root;
  root.next = &root;
  root.prev = &root;

  for (int i = 0; i < n; i++) {
    scanf("%s", s);
    if (s[0] == 'i') {
      LList *e = malloc(sizeof(LList));
      scanf("%d", &e->v);
      add(&root, e);
    } else if (s[0] == 'd') {
      if (s[6] == 'F') {
        removeElem(root.next);
      } else if (s[6] == 'L') {
        removeElem(root.prev);
      } else {
        int v;
        scanf("%d", &v);
        LList *e = findElem(&root, v);
        if (e) {
          removeElem(e);
        }
      }
    }
  }
  printList(&root);
  return 0;
}