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

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

typedef struct node* NodePointer;

NodePointer N;

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

int main(){
  int i, n, a;
  char c[11];

  scanf("%d",&n);

  init();

  for(i = 1; i <= n; i++){
    scanf("%s",c);

    if(strcmp(c, "deleteFirst") == 0) deleteFirst();

    else if(strcmp(c, "deleteLast") == 0)deleteLast();

    else if(strcmp(c, "insert") == 0 || strcmp(c, "delete") == 0){
      scanf("%d",&a);

      if(c == "insert") insert(a);

      else delete(a);
    }
  }

  printList();

  return 0;
}

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

void insert(int a){
  NodePointer new;
  static int count = 0;

  new = malloc(sizeof(struct node));

  new->number = a;
  
  if(count == 0){
    new->next = N;
    N->next = new;
    new->prev = N;
    N->prev = new;
    count++;
  }

  else{
    new->next = N->next;
    N->next->prev = new;
    N->next = new;
    new->prev = N;
    count++;
  }
}

void delete(int a){
  int judge = 0;
  NodePointer x;
  NodePointer y; 
  
  for(y = N->next; y != N; y = y->next){
    if(y->number == a){
      judge = 1;
    }
  }
  
  if(judge == 1){
    y = N->next;
    while(y != N){
      if(y->number == a)
        break;
      y=y->next;
    }
    x = y->prev;
    x->next = y->next;
    x->next->prev = x;
    free(y);
  }
}

void deleteFirst(void){
  NodePointer x = N->next;
  N->next = x->next;
  x->next->prev = N;
  free(x);
}

void deleteLast(void){
  NodePointer x = N->prev;
  N->prev = x->prev;
  x->prev->next = N;
  free(x);
}

void printList(void){
  NodePointer x = N->next;
  int y = 1;

  while(x != N){
    if (y == 0) printf(" ");
    printf("%d", x->number);
    x = x->next;
    y = 0;
  }

  printf("\n");
}