#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 200000

struct node{
  int key;
  struct node *next;
  struct node *prev;
};
typedef struct node * NodePointer;
NodePointer nil;
void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void insert(int key){
  int i = 0, n;
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next = nil->next;
  nil->next = x;
}

void delete(int key){
  int i=0;
  NodePointer cur = nil->next;
  if(key == -1){
    nil->next = nil->next->next;
    nil->next->next->prev = nil;
  }
  else if(key == -2){
    while(cur->next->next != nil) cur = cur->next;
    cur->next = nil;
  }
  else{
    while(cur->next->key != key){
      if(cur->next == nil){
	i = 1;
	break;
      }
      cur = cur->next;
    }
    if(i == 0){
    cur->next = cur->next->next;
    cur->next->next->prev = cur;
    }
  }
}

void printList(){
  NodePointer 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");
}

int main(){
  int i, n, key;
  char s[20];
  init();
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%s",s);
    if(s[0] == 'i'){
    scanf("%d",&key);
    insert(key);
    }
  else if(s[0] == 'd'){
    if(s[6] == 'F')
      delete(-1);
    else if(s[6] == 'L')
      delete(-2);
    else{
      scanf("%d",&key);
      delete(key);
    }
  }
  }
  printList();
  return 0;
}