#include<stdio.h>
#include <string.h>
#include <stdlib.h>
struct node {
    int key;
    struct node *prev, *next;
};
struct node *nil;

void insert(int key);
void delete(struct node *t);
struct node *linear_search(int key);
void print_list();

int main(void) {
  int i, n, key;
  char command[10];
  nil = (struct node*)malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%s",command);
    if(strlen(command) > 6) {
      if( command[6] == 'F') delete(nil->next);
      else delete(nil->prev);
    }else {
      scanf("%d", &key);
      if (command[0] == 'd') delete(linear_search(key));
      else insert(key);
    }
  }
  print_list();
  return 0;
}

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

void delete(struct node *t) {
  if (t == nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

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

void print_list() {
  int isf = 0;
  struct node *current = nil->next;
  while(current != nil) {
    if(isf++) putchar_unlocked(' ');
    printf("%d", current->key);
    current = current->next;
  }
  putchar_unlocked('\n');
}
