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

void init();
void insert(int);
void deleteN();
void deleteFirst();
void deleteLast();
void deleteK(int);
void print();

struct Node{
  int key;
  struct Node *prev, *next;
};

struct Node *nil;

int main(){
  int key,num,i;
  int size = 0;
  char array[20];
  int p = 0;
  int d = 0;

  scanf("%d",&num);
  init();

  for(i = 0;i < num;i++){
    scanf("%s%d",array,&key);
    if(array[0] == 'i'){
      insert(key);
      p++;
      size++;
    }
    else if(array[0] == 'd'){
      if(strlen(array) > 6){
        if(array[6] == 'F'){
          deleteFirst();
        }
        else if(array[6] == 'L'){
          deleteLast();
        }
      }
      else{
        deleteK(key);
        d++;
      }
      size--;
    }
  }
  print();
  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 = (struct Node *)malloc(sizeof(struct Node));
  nil -> next = nil;
  nil -> prev = nil;
}

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

void deleteN(struct Node *b){
  if(b == nil){
    return;
  }
  b -> prev -> next = b -> next;
  b -> next -> prev = b -> prev;
  free(b);
}

void deleteFirst(){
  deleteN(nil -> next);
}

void deleteLast(){
  deleteN(nil -> prev);
}

void deleteK(int key){
  deleteN(listSearch(key));
}

void print(){
  int count = 0;

  struct Node *cur;
  cur = nil -> next;
  while(1){
    if(cur == nil){
      break;
    }
    if(count++ > 0){
      printf(" ");
    }
    printf("%d",cur -> key);
    cur = cur -> next;
  }
  printf("\n");
}

