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

#define MAX 2000000000

typedef struct node{
  
  struct node *next;

  struct node *prev;

  unsigned int key;

}*NodePointer;

NodePointer head, last;

NodePointer make_1node(int, NodePointer);

NodePointer search(int);

void insert(int);

void delete(int);

void deleteFirst();

void deleteLast();

int main(){

  int i, n, key;

  char com[15];

  NodePointer node;

  last = make_1node(0, NULL);

  head = make_1node(0, last);

  scanf("%d", &n);

  if(MAX < n)
    exit(8);

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

    scanf("%s", com);

    if(strlen(com) == 6){

      scanf("%d", &key);

      if(com[0] == 'i')
	insert(key);
      else
	delete(key);      

    }

    else if(com[6] == 'F')
      deleteFirst();

    else
      deleteLast();

  }

  for(node = head->next; node != last; node = node->next){

    if(node->next == last)
      printf("%d\n", node->key);

    else
      printf("%d ", node->key);

  }

  return 0;

}


NodePointer make_1node(int x, NodePointer node){

  NodePointer newnode;

  newnode = (NodePointer)malloc(sizeof(struct node));

  newnode->key = x;

  newnode->next = node;

  return newnode;

}

NodePointer search(int x){

  NodePointer node;

  node = head->next;

  while((node != head) && (node->key != x)){

    if(node == last){

      node = NULL;

      break;

    }

    node = node->next;

  }

  return node;

}

void insert(int x){

  NodePointer node;

  node = (struct node *)malloc(sizeof(struct node));

  node->key = x;

  node->next = head->next;

  head->next->prev = node;

  head->next = node;

  node->prev = head;

}

void delete(int x){

  NodePointer deletenode;

  deletenode = search(x);

  if(deletenode != NULL){

    deletenode->prev->next = deletenode->next;

    deletenode->next->prev = deletenode->prev;

  }

}

void deleteFirst(){

  head->next->next->prev = head->next->prev;

  head->next = head->next->next;

}

void deleteLast(){

  last->prev->prev->next = last->prev->next;

  last->prev = last->prev->prev;

}