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

struct node{
  int key;
  struct node *next;
};

typedef struct node *NodePointer;

NodePointer insert(int);
NodePointer delete(int);
NodePointer make_1node(int, NodePointer); 
void deletefirst(void);
void deletelast(void);
NodePointer finditem(int);
void listprint(void);

NodePointer head;
int count = 0;

int main(){
  int n, i, b;
  char c[15];

  scanf("%d", &n);
  head = make_1node(0, NULL);
  for(i = 0;i < n; i++){
    scanf("%s%d", c, &b);
    if(strcmp(c, "insert") == 0){
      insert(b);
    }
    else if(strcmp(c, "delete") == 0){
      delete(b);
    }
    else if(strcmp(c, "deleteFirst") == 0){
      deletefirst();
    }
    else if(strcmp(c, "deleteLast") == 0){
      deletelast();
    }
  }
  listprint();
  return 0;
}

NodePointer insert(int keydata){
  NodePointer newnode;

  if(finditem(keydata) == NULL){
    newnode = make_1node(keydata, head->next);
    head->next = newnode;
    return newnode;
  }
  else return NULL;
}

void listprint(void){
  NodePointer n;

  for(n = head->next;n->next != NULL;n = n->next){
    printf("%d ", n->key);
  }
  printf("%d\n", n->key);
}

NodePointer finditem(int keydata){
  NodePointer n;

  for(n = head;n->next != NULL;n = n->next){
    if(n->next->key == keydata){
      count++;
      if(count == 1){
	return n;
      }
    }
  }
  return NULL;
}

NodePointer make_1node(int keydata, NodePointer p){
  NodePointer n;

  if((n = malloc(sizeof(struct node))) == NULL){
    exit(8);
  }
  n->key = keydata;
  n->next = p;
  return n;
}

NodePointer delete(int a){
  NodePointer n, delnode;

  if((n = finditem(a)) != NULL){
    delnode = n->next;
    n->next = delnode->next;
    free(delnode);
    return n;
  }
  return NULL;
}
 
void deletefirst(void){ 
  delete(head->next->key);
}

void deletelast(void){
  NodePointer n;

  for(n = head;n->next != NULL;n = n->next);
  delete(n->key);
}