#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define M 20


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

struct Node *nil;

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

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


void pr_l(){

  struct Node *cu = nil->next;
  int isf = 0;
  while(1){
    if(cu == nil) break;
    if(isf++>0)
      printf(" ");
    printf("%d",cu->key);
    cu = cu->next;
  }
  printf("\n");
}

void del(struct Node *s){
  if(s == nil) return;
  s->prev->next = s->next;
  s->next->prev = s->prev;
  free(s);
}
void delF(){
  del(nil->next);
}

void del_L(){
  del(nil->prev);
}

void delK(int key){
  del(listS(key));
}


void insert(int a){
  struct Node *z = (struct Node *)malloc(sizeof(struct Node));
  z->key =a;

  z->next = nil->next;
  nil->next->prev = z;
  nil->next = z;
  z->prev = nil;
}
  


int main(){
  int k,i,l;
  int s = 0,np = 0,nd = 0;
  char c[M];

  scanf("%d",&l);
  ini();
  for(i = 0;i<l;i++){
    scanf("%s%d",c,&k);
    if(c[0] == 'i'){
      insert(k);
      np++;s++;
    }
    else if(c[0] == 'd'){
      if(strlen(c) >6){
	if(c[6] == 'F') delF();
	else if(c[6] == 'L') del_L();
      }else{
	delK(k);
	nd++;
      }
      s--;
    }
  }
  pr_l();

  return 0;
}
