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

typedef struct node {
  int x;
  struct node* prev;
  struct node* next;
} list;
list* head;
list* tail;

list* newnode(int x) {
  list* res = (list*)malloc(sizeof(list));
  res->x = x;
  res->prev = NULL;
  res->next = NULL;
  return res;
}

void deletenode(list* p) {
  p->prev->next = p->next;
  p->next->prev = p->prev;
  free(p);
}

void insert(int x) {
  list* p = newnode(x);
  p->next = head->next;
  p->prev = head;
  head->next->prev = p;
  head->next = p;
}

void delete(int x) {
  list* p;
  for(p = head->next; p != head; p = p->next) {
    if(p->x == x) {      
      deletenode(p);
      break;
    }
  }
}

void deleteFirst() {
  deletenode(head->next);
}

void deleteLast() {
  deletenode(tail->prev);
}

void print() {
  list* p;
  int izryt = 0;
  for(p = head->next; p != tail; p = p->next) {
    if(izryt) printf(" ");
    printf("%d", p->x);
    izryt = 1;
  }
  puts("");
}

int main() {
  int n;
  int i;
  char com[256];
  int x;
  head = newnode(-1);
  tail = newnode(-1);
  head->next = head->prev = tail;
  tail->prev = tail->next = head;
  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    scanf("%s", com);
    if(strcmp(com, "insert") == 0) {
      scanf("%d", &x);
      insert(x);
    } else if(strcmp(com, "delete") == 0) {
      scanf("%d", &x);
      delete(x);
    } else if(strcmp(com, "deleteFirst") == 0) {
      deleteFirst();
    } else if(strcmp(com, "deleteLast") == 0) {
      deleteLast();
    }    
  }
  print();
  return 0;
}