#include <stdio.h>
#include <malloc.h>
#include <string.h>
struct node{
  struct node *next;
  struct node *prev;
  int key;
};
typedef struct node * NodePointer;
struct node nil;

void insert(int);
void delete(int);
void deleteFirst(void);
void deleteLast(void);
void init(){
	nil.next=NULL;
	nil.prev=NULL;
}
struct node nil;

int main(){
	NodePointer p;
	int i, n, key;
	char com[12];
	scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
      if ( com[0] == 'i' ) {
      insert(key);
        } else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
        if ( com[6] == 'F' ) {
          deleteFirst();
        } else if ( com[6] == 'L' ) {
          deleteLast();
        }
      } else {
        delete(key);
        }
      }
  }
  for(p=nil.next;p->next!=NULL;p=p->next){
    printf("%d ",p->key);
  }
  printf("%d\n",p->key);
  return 0;
}


void insert(int key){
	NodePointer temp;
	temp=(NodePointer)malloc(sizeof(struct node));
	temp->key=key;
	temp->next=nil.next;
	temp->prev=nil.prev;
	nil.next=temp;
}

void delete(int key){
	NodePointer p, q;
	p=nil.next;
	q=&nil;
	while(p!=NULL&&p->key!=key){
		q = p;           /*This q have prevew of p*/
    p = p->next;
	}
	if(p!=NULL){
    q->next=p->next;
    p->next->prev=p;
    free(p);
  }
}

void deleteFirst(){
	NodePointer p, q;
	p=nil.next;
	q=&nil;
	q->next=p->next;
	p->next->prev=p;
	free(p);
}

void deleteLast(){
	NodePointer p, q;
	p=nil.next;
	q=&nil;
	while(p!=NULL){
		q = p;           /*This q have prevew of p*/
    p = p->next;
	}
	if(p!=NULL){
    q->next=p->next;
    p->next->prev=p;
    free(p);
  }
}