#include<stdio.h>
#include<stdlib.h>
#define N 256
#define O 0
#define S 6

typedef struct Node {
  int x;
  struct Node *prev;
  struct Node *next;
} Node;

Node *head,*tail;

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

int main(int argc,char **argv) {

  int i,n,x;
  char buf[N],tmp[N];
    scanf("%d\n",&n);
  for (i=O;i<n;++i) {
    fgets(buf,N, stdin);
    if (buf[O]=='i' || buf[S]==' '){
      sscanf(buf,"%s %d",tmp,&x);
      if (buf[0]=='i'){
	insert(x);
      }
      else{
	delete(x);
      }
    }
    else if(buf[S]=='F'){
      deleteFirst();
    }
    else if (buf[S]=='L'){
      deleteLast();
    }
  }
  dump();
  return O;
}

void dump(){
  int m=O;
  Node *p=head;
  while (p!=NULL) {
    if (m==O){
      printf("%d",p->x);
    }
    else{
      printf(" %d",p->x);
    }
    ++m;
    p=p->next;
  }
  printf("\n");
}

void insert(int x) {
  Node *nod=malloc(sizeof(Node));;
  nod->x=x;
  nod->prev=NULL;
  nod->next=NULL;

  if(head==NULL) {
    head=nod;
    tail=nod;
  }
  else{
    nod->next=head;
    head->prev=nod;
    head=nod;
  }
}

void delete(int x) {
  Node *p=head;
  int flg=O;

  while(flg==O && p!=NULL){
    if(p->x==x){
      Node *c=p;
      if(c->prev!= NULL) {
        p->prev->next=c->next;
      }
      else{
        head=c->next;
      }
      if(c->next!=NULL){
        p->next->prev=c->prev;
      }
      else{
        tail=c->prev;
      }
      flg=1;
    }
    else{
      p=p->next;
    }
  }
}
void deleteFirst() {
  if(head==tail) {
    head = NULL;
    tail = NULL;
  } else if(head!= NULL) {
    if (head->next!=NULL){
      head->next->prev=NULL;
    }
    head=head->next;
  }
}

void deleteLast(){
  if(head==tail){
    head=NULL;
    tail=NULL;
  }
  else if(tail!=NULL){
    if(tail->prev!= NULL){
      tail->prev->next=NULL;
    }
    tail=tail->prev;
  }
}



