#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct node{
  struct node *next, *prev;
  int key;
}node;
void insert(int);
void delete(node*);
void deleteFirst(void);
void deleteLast(void);
node* finder(int);
void print(void);
node *head;
int main(){
  int n, i, key;
  char func[11];
  scanf("%d",&n);
  head = (node *)malloc(sizeof(node));
  head->next = head->prev = head;
  for(i=0; i<n; i++){
    scanf("%s%d",func,&key);
    if(func[0] == 'i') insert(key);
    else if(func[0] == 'd'){
      if(func[6] == 'F') deleteFirst();
      else if(func[6] == 'L') deleteLast();
      else delete(finder(key));
    }
  }
  print();
  return 0;
}
void insert(int key){
  node *n = (node *)malloc(sizeof(node));
  n->key = key;
  n->next = head->next;
  head->next->prev = n;
  head->next = n;
  n->prev = head;
}
void delete(node *del){
  if(del == head) return;
  del->prev->next = del->next;
  del->next->prev = del->prev;
  free(del);
}
void deleteFirst(void){
  delete(head->next);
}
void deleteLast(void){
  delete(head->prev);
}
node* finder(int key){
  node *n;
  for(n=head->next; n != head && n->key != key; n=n->next);
  return n;
}
void print(void){
  node *n;
  for(n=head->next; n!=head; n=n->next){
    printf("%d",n->key);
    if(n != head->prev) printf(" ");
  }
  printf("\n");
}