#include <stdio.h>
#include <stdlib.h>
#define buf_size 20

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

Node *head, *tail;

void init(){
  Node *node = ( Node * )malloc( sizeof( Node ) );
  head = node;
  tail = node;
  node -> next = tail;
  node -> prev = head;
}

void kill(){
  Node *node = head -> next;
  while( node != tail ){
    Node *next = node -> next;
    free( node );
    node = next;
  }
  free( tail );
}

void insert( int key ){
  Node *node = ( Node * )malloc( sizeof( Node ) );
  node -> key = key;
  node -> prev = head;
  node -> next = head -> next;
  head -> next -> prev = node;
  head -> next = node;
}

void delete( int key ){
  Node *node = head -> next;
  while( node != tail ){
    if( node -> key == key ){
      node -> next -> prev = node -> prev;
      node -> prev -> next = node -> next;
      free( node );
      break;
    }
    node = node -> next;
  }
}

void deleteFirst(){
  if( head -> next == tail ) return;
  Node *node = head -> next;
  node -> next -> prev = head;
  head -> next = node -> next;
  free( node );
}

void deleteLast(){
  if( head -> next == tail ) return;
  Node *node = tail -> prev;
  node -> prev -> next = tail;
  tail -> prev = node -> prev;
  free( node );
}

void print(){
  if( head -> next == tail ) return;
  Node *node = head -> next;
  while( node -> next != tail ){
    printf("%d ", node -> key );
    node = node -> next;
  }
  printf("%d\n", node -> key );
}

int main( void ){
  int n, key;
  scanf("%d\n", &n );
  init();
  while( n-- > 0 ){
    char buf[ buf_size ];
    scanf("%s", buf );
    if( buf[0] == 'i' ){
      scanf("%d\n", &key );
      //printf("Insert [%d]\n", key );                                                                                        
      insert( key );
      //print();                                                                                                              
    }
    else if( buf[6] == '\0' ){
      scanf("%d\n", &key );
      //printf("Delete [%d]\n", key );                                                                                        
      delete( key );
      //print();                                                                                                              
    }
    else if( buf[6] == 'F' ){
      scanf("\n");
      //printf("DeleteFirst\n");                                                                                              
      deleteFirst();
      //print();                                                                                                              
    }
    else if( buf[6] == 'L' ){
      scanf("\n");
      //printf("DeleteLast\n");                                                                                               
      deleteLast();
      //print();                                                                                                              
    }
  }
  print();
  return 0;
}
    
    
    
    
