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

struct Node{
  int key;
  struct Node *back, *next;
};

struct Node *nil;
 
void initialize(void);
void insert(int);
struct Node* listsearch(int);
void delete_n(struct Node *t);
void delete_f(void);
void delete_l(void);
void delete_k(int);
  
int main(){

  struct Node *now;
  int n, i, key;
  char command[12];
  
  scanf("%d",&n);
  initialize();
  for(i=0;i<n;i++){
    scanf("%s %d",command,&key);
    if(command[0]=='i') insert(key);
    else if(command[0]=='d'){
      if(strlen(command)==6) delete_k(key);
      if(strlen(command)>6){
        if(command[6]=='F') delete_f();
        else if(command[6]=='L') delete_l();
      }
    }
  }
  
  now=nil->next;
  i=0;

  while(1){
    if(now==nil) break;
    if(i>0) printf(" ");
    i++;
    printf("%d",now->key);
    now=now->next;
  }
  printf("\n");

  return 0;
}

void initialize(){
  nil=(struct Node *)malloc(sizeof(struct Node));
  nil->next=nil;
  nil->back=nil;
}

void insert(int key){
  
  struct Node *a;
  
  a=(struct Node *)malloc(sizeof(struct Node));
  a->key=key;
  a->next=nil->next;
  nil->next->back=a;
  nil->next=a;
  a->back=nil;
}

struct Node* listsearch(int key){
  
  struct Node *now;
  now=nil->next;
  while (now!=nil && now->key!=key){
    now=now->next;
  }
  return now;
}

void delete_n(struct Node *d){
  
  if(d==nil) return;
  d->back->next=d->next;
  d->next->back=d->back;
  free(d);
}

void delete_f(){
 
  delete_n(nil->next);
}

void delete_l(){

  delete_n(nil->back);
}

void delete_k(int key){

  delete_n(listsearch(key));
}




