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

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

struct node *nil;

void init() {
  nil = (struct node *)malloc(sizeof(struct node));
  nil->prev = NULL;
  nil->next = NULL;
}

struct node *list_search(int key) {
  struct node *s = nil->next;
  while(1) {
    s = s->next;
    if(s->key == key)
      return s;
  }
}

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

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

void delete_key(int key) {
  delete_node(list_search(key));
}

void delete_first() {
  delete_node(nil->next);
}

void delete_last() {
  delete_node(nil->prev);
}

void print() {
  struct node *p = nil->next;
  int count = 0;
  while(1) {
    if(p == nil)
      break;
    if(count++ > 0)
      printf(" ");
    printf("%d", p->key);
    p = p->next;
  }
  printf("\n");
}

int main() {
  int key, n, i;
  int size = 0;
  char command[20];
  int np = 0;
  int nd = 0;

  scanf("%d", &n);
  init();
  for(i = 0; i < n; i++) {
    scanf("%s%d", command, &key);
    if(strcmp(command, "insert") == 0) {
      insert(key);
      np++;
      size++;
    }
    else if(strcmp(command, "deleteFirst") == 0) {
      delete_first();
      size--;
    }
    else if(strcmp(command, "deleteLast") == 0) {
      delete_last();
      size--;
    }
    else {
      delete_key(key);
      nd++;
      size--;
    }
  }
  print();
  return 0;
}