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

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

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

Data head = { NULL, NULL, -1 };

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

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

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

  printer();

  return 0;
}

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

void insert(int x){
  Data *newlist;

  newlist = (Data *)malloc(sizeof(Data));
  newlist->next = head.next;
  if(head.next != NULL){
    head.next->prev = newlist;
  }
  head.next = newlist;
  newlist->prev = &head;

  newlist->x = x;
}

void delete(int x){
  Data *nowdata;

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

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

void deleteLast(void){
  Data *nowdata = &head;
  while(1){
    if(nowdata->next != NULL){
      nowdata = nowdata->next;
    } else{
      nowdata->prev->next = NULL;
      free(nowdata);
      break;
    }
  }
}

