#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
struct node{
  int key;
  struct node *next;
  struct node *prev;
};
 
typedef struct node * NodePointer;
 
NodePointer nil;
void insert(int key);
int delete(int key);
int deleteFirst();
int deleteLast();
void init();
 
main(){
  int n, i, keydata;
  char com[12];
  NodePointer p;
  scanf("%d",&n);
  nil=malloc(sizeof(struct node));
  init();
  
  for (i=0;i<n;i++){
    scanf("%s",com);
    if(strlen(com)>6){
      if(com[6]=='F') {
	deleteFirst();
      }else{
	deleteLast();
      }
    }else{
      scanf("%d",&keydata);
      if(com[0]=='i'){
	insert(keydata);
      }else{
	delete(keydata);
      }
    }
  }

  for(p=nil->next;p->next!=nil;p=p->next){
    printf("%d ",p->key);
  }
  printf("%d\n",p->key);
  free(nil);
  return 0;
}
 
void insert(int keydata){
    NodePointer x;
    x=malloc(sizeof(struct node));
    x->key=keydata;
    x->next=nil->next;
    x->prev=nil;
    nil->next=x;
    x->next->prev=x;
}
 
int delete(int keydata){
  NodePointer p;
  p=nil->next;
  while(p!=NULL&&p->key!=keydata){
    p=p->next;
  }
  if(p==NULL){
    return 0;
  }else{
    p->prev->next=p->next;
    p->next->prev=p->prev;
    free(p);
    return 0;
  }
}
 
int deleteFirst(){
    NodePointer p,q;
    p=nil->next;
    q=nil;
    p->next->prev=q;
    nil->next=p->next;
    free(p);
    return 0;
}
 
int deleteLast(){
    NodePointer p;
    p=nil->prev;
    p->prev->next=nil;
    nil->prev=p->prev;
    free(p);
    return 0;
}

void init(){
  nil->next=nil;
  nil->prev=nil;
}