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

struct node{
  int data;
  struct node *prev,*next;
};

struct node *head;

struct node *find(int key){
  struct node *p;
  p=head->next;
  while(p != head && p->data != key){
    p=p->next;
  }
  return p;
}

void insert(int data){
  struct node *newnode;
  newnode = (struct node *)malloc(sizeof(struct node));
  newnode->data=data;
  newnode->next=head->next;
  head->next->prev=newnode;
  head->next=newnode;
  newnode->prev=head;
}

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

void deleteFirst(){
  delete(head->next);
}

void deleteLast(){
  delete(head->prev);
}

int main(){
  int data,n,i;
  char command[12];
  struct node *out;
  scanf("%d",&n);
  if(n>2000000) exit(2);
  head = (struct node *)malloc(sizeof(struct node));
  head->next=head;
  head->prev=head;
  for(i=0;i<n;i++){
    scanf("%s",command);
    if(strcmp(command,"insert") == 0){  // insert
      scanf("%d",&data);
      insert(data);
    }
    else if(strcmp(command,"delete")==0){ // delete and so on
      scanf("%d",&data);
      delete(find(data));
    }
    else if(strcmp(command,"deleteFirst")==0){
      deleteFirst();
    }
    else if(strcmp(command,"deleteLast")==0){
      deleteLast();
    }
  }
  out=head->next;
  i=0;
  while(1){
    if(out == head) break;
    if(i>0) printf(" ");
    printf("%d",out->data);
    out=out->next;
    i++;
  }
  printf("\n");
  return 0;
}

