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

typedef struct {
  int key;
  struct Node *pre,*next;
}Node;

Node *nil;

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

void renketu(){
  nil=(Node *)malloc(sizeof(Node));
  nil->pre=nil;
  nil->next=nil;
}

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

 Node search(int key){
 Node *ser=nil->next;
 
  while(nil!=ser && ser->key!=key){
    ser=ser->next;
  }
  return ser;
}

void delete(Node *a){
  if(a==nil) return;
  a->pre->next=a->next;
  a->next=t->pre;
  free(a);
}

void fdelet(){
  delete(nil->next);
}

void ldelete(){
  delete(nil->pre);
}

void keydelete(int key){
  delete(search(key));
}

int main(){
  int i,n,key;
  char a[20];

  scanf("%d",&n);
  
  renketu();

  for(i=0;i<n;i++){
    scanf("%s%d",a,&key);
      if(a[0]=='i'){ insert(key);
      }else if(a[0]=='d'){
	if(a[6]=='F'){ fdelete();
	} else if(a[6]=='L'){ ldelete();
	} else {
	  keydelete(key);
	}
      }
  }
  
  print();

  return 0;
 
  
}