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

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

struct node *  nil;

struct node * listSearch(int key);
void init();
void printList();
void deleteNode(struct node * t);
void deleteFirst();
void deleteLast();
void delete(int key);
void insert(int key);

int main(){
  int key, n, i;
  int size = 0;
  char a[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", a, &key);
    if(!(0 <= key && key <= 2000000000)){printf("error");}
    if (a[0] == 'i' ){
      insert(key);
      np++;
      size++;
    }
    else if (a[0] == 'd' ){
      if (strlen(a) > 6){
	if (a[6] == 'F' ) deleteFirst();
	else if (a[6] == 'L' ) deleteLast();
      } else {
	delete(key);
	nd++; 
      }
      size--;
    }
    if ( size > 1000000 ){
      printf("error");
    }
  }

  
  if(!( np+nd <= 2000000)){printf("error") ;}
  if(!( nd <= 20)){printf("error") ;}
  printList();


  return 0;
}

struct node * listSearch(int key){
  struct node * cur = nil->next;
  while( cur != nil && cur->key != key ){
    cur = cur->next;
  }
  return cur;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  struct node * cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(struct node * t){
  t->prev->next = t->next;
  t->next->prev = t->prev;
}

void deleteFirst(){
  struct node * t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  struct node * t = nil->prev;
  if ( t == nil ) return;
  deleteNode(t);
}

void delete(int key){
  struct node * t = listSearch(key);
  if ( t == nil ) return;
  deleteNode(t);
}


void insert(int key){
  struct node * x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

