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

typedef struct d{
  struct d *prev;
  struct d *next;
  int x;
}Data;

void init(void);
void printer(void);
void insert(int);
void delete(int);
void deleteFirst(void);
void deleteLast(void);

Data head, end;

void init(){
  head.prev = NULL;
  head.next = &end;
  head.x = -1;
  end.prev = &head;
  end.next = NULL;
  head.x = -1;
}

int main(){
  int i, n, x;
  char command[12];

  init();

  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%s %d",command ,&x);

    if(!strcmp(command, "insert")){
      //printf("%d  insert\n",i);
      insert(x);
    } else if(!strcmp(command, "delete")){
      //printf("%d  delete\n",i);
      delete(x);
    } else if(!strcmp(command, "deleteFirst")){
      //printf("%d  deleteFirst\n"i);
      deleteFirst();
    } else if(!strcmp(command, "deleteLast")){
      //printf("%d  deleteLast\n"i);
      deleteLast();
    }
  }

  printer();

  return 0;
}

void printer(void){
  Data *nowdata ;
  for(nowdata = head.next; nowdata != &end; nowdata = nowdata->next){
    printf("%d",nowdata->x);
    if(nowdata->next != &end){
      printf(" ");
    }
  }
  printf("\n");
}

void insert(int x){
  Data *newlist;

  newlist = (Data *)malloc(sizeof(Data));
  newlist->next = head.next;
  head.next->prev = newlist;
  head.next = newlist;
  newlist->prev = &head;

  newlist->x = x;
}

void delete(int x){
  Data *nowdata;

  for(nowdata=head.next; nowdata != &end; nowdata = nowdata->next){
    if(nowdata->x == x){
      nowdata->prev->next = nowdata->next;
      nowdata->next->prev = nowdata->prev;
      free(nowdata);
      break;
    }
  }
}

void deleteFirst(void){
  head.next->next->prev = &head;
  head.next = head.next->next;
}

void deleteLast(void){
  end.prev->prev->next = &end;
  end.prev = end.prev->prev;
}

