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

struct node{
  int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

void insert(int);
void delete(int);
void deleteFirst(void);
void deleteLast(void);
void printNode(void);

NodePointer nil;


int main(void){

  int n,i,x;
  char op[15];

  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++){

    scanf("%s",op);
    if(strlen(op) < 7) scanf("%d",&x);

    if(strcmp(op,"insert")==0) insert(x);
    else if(strcmp(op,"delete")==0) delete(x);
    else if(strcmp(op,"deleteFirst")==0) deleteFirst();
    else if(strcmp(op,"deleteLast")==0)deleteLast();

  }

    printNode();

    return 0;
}


void insert(int key){

  NodePointer x;

  x = malloc(sizeof(struct node));
  x->key = key;

  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;

}


void delete(int key){

  int i;
  NodePointer x;

  x = nil->next;

  while(1){

    if(x == nil) break;
    if(x->key == key)break;

    x = x->next;

  }

  if(x == nil){
    printf("error\n");
    return;
  }

  else{
    x->prev->next = x->next;
    x->next->prev = x->prev;

  free(x);
  }

}

void deleteFirst(){

  nil->next->prev->next = nil->next->next;
  nil->next->next->prev = nil->next->prev;

}

void deleteLast(){

  nil->prev->prev->next = nil->prev->next;
  nil->prev->next->prev = nil->prev->prev;

}

void printNode(){

  NodePointer x;

  for(x = nil->next ; x != nil ; x = x->next){

    printf("%d",x->key);
    if(x != nil->prev) printf(" ");

  }

  printf("\n");

}