#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef struct node *link;

struct node{
  int item;
  link next;
};

int main(void){
  int n, i, j, getitem, size = 0;
  char s[256];
  link head;
  head = malloc(sizeof(*head));
  head->item = -1;
  head->next = NULL;
  
  scanf("%d", &n);
  
  for(i = 0; i < n; i++){
    scanf("%s", s);
    if(!strcmp(s, "insert")){ //insert
      scanf("%d", &getitem);
      link x;
      x = malloc(sizeof(*x));
      x->item = getitem;
      x->next = head;
      head = x;
      size++;
    }else if(!strcmp(s, "delete")){ //delete
      scanf("%d", &getitem);
      link x;
      x = malloc(sizeof(*x));
      x = head;
      if(head->item == getitem){
	head = head->next;
	size--;
	continue;
      }
      while(x->next->item != -1){
	if(x->next->item == getitem){
	  x->next = x->next->next;
	  size--;
	  break;
	}else{
	  x = x->next;
	}
      }
    }else if(!strcmp(s, "deleteFirst")){ //deleteFirst
      head = head->next;
      size--;
    }else if(!strcmp(s, "deleteLast")){ //deleteLast
      link x;
      x = malloc(sizeof(*x));
      x = head;
      for(j = 0; j < size-2; j++){
	x = x->next;
      }
      x->next = x->next->next;
      size--;
    }
  }

  link x;
  x = malloc(sizeof(*x));
  x = head;
  while(!(x->next == NULL)){
    printf("%d", x->item);
    if(x->next->item == -1) break;
    printf(" ");
    x = x->next;
  }
  
  printf("\n");
  return 0;
}