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

struct node{
  int key;
  struct node *next;
  struct node *prev;
};
typedef struct node *nodePointer;
nodePointer head;
nodePointer tail;


nodePointer listSearch(int key){
  nodePointer n;
  for(n=head->next; n->next!=NULL; n=n->next){
    if(n->key==key)return n;
  }
  return NULL;
}


void insert(int key){
  nodePointer n;
  n=malloc(sizeof(struct node));
  n->key=key;
  n->prev=head;
  n->next=head->next;
  head->next->prev=n;
  head->next=n;
}

void delete(int key){
  nodePointer n;
  n=listSearch(key);
  if(n != NULL){
    n->prev->next=n->next;
    n->next->prev=n->prev;
    free(n);
  }
}

void deleteFirst(int key){
  nodePointer n;
  n=head->next;
  head->next=n->next;
  n->next->prev=head;
  free(n);
}

void deleteLast(int key){
  nodePointer n;
  n=tail->prev;
  n->prev->next=tail;
  tail->prev=n->prev;
  free(n);
}


int main(){
  int key,n,i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  nodePointer P;
  head=malloc(sizeof(struct node));
  tail=malloc(sizeof(struct node));
  head->next=tail;
  head->prev=NULL;
  tail->next=NULL;
  tail->prev=head;
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst(key);
	else if ( com[6] == 'L' ) deleteLast(key);
      } else {
	delete(key); nd++;
      }
      size--;
    }
  }
  for(P=head->next; P->next!=NULL; P=P->next){
    if(P != head->next) printf(" ");
    printf("%d", P->key);
  }
  printf("\n");

  return 0;
}

