#include <stdio.h>
#include <stdlib.h>
struct Node{
  int k;
  struct Node *n;
 struct  Node *p;
};
typedef struct Node Node; 

Node *nil;
void insert(int);
void delete(Node *);
void deletefirst();
void deletelast();
Node * search(int);
void deletek(int);
void print();



int main(){
  int n,i,d;
  char c[12];
  nil=(Node *)malloc(sizeof(Node));
  nil->n=nil;
  nil->p=nil;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",c);

    if(c[0]=='i') {
      scanf("%d",&d);
      insert(d);

    }
  else if(c[0]=='d'&&c[6]=='F') deletefirst();
  else if(c[0]=='d'&&c[6]=='L') deletelast();

  else {
    scanf("%d",&d);
    deletek(d);
  }
  }

  print();

  return 0;
}



void insert(int d){
  Node *x;
  x=(Node *)malloc(sizeof(Node));
  x->k=d;
  x->n=nil->n;
  nil->n->p=x;
  nil->n=x;
  x->p=nil;
}
void delete(Node *c){

  if(c==nil) return;
  c->p->n=c->n;
  c->n->p=c->p;
  free(c);
  
}
void deletefirst(){
  delete(nil->n);
}
void deletelast(){
  delete(nil->p);
}
void deletek(int d){
  delete(search(d));

}

Node* search(int d){
  Node *c;
  c=nil->n;
  while(c!=nil&&c->k!=d){
    c=c->n;
  }
  return c;
}

void print(){
  Node *c=nil->n;
  int i;
  while(1){
    if(c==nil)break;
    if(i++>0)printf(" ");
    printf("%d",c->k);
    c=c->n;
  }
  printf("\n");
}