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

struct Node{
  int key;
  struct Node *pre,*nex;
};

struct Node *nil;

void Insert(int key){
  struct Node *x;

  x=(struct Node*)malloc(sizeof(struct Node));
  x->key=key;
  x->nex=nil->nex;
  nil->nex->pre=x;
  nil->nex=x;
  x->pre=nil;
}

struct Node *listserch(int key){
  struct Node* gol=nil->nex;
  while(gol!=nil&&gol->key!=key){
    gol=gol->nex;
  }
  return gol;
}

void Delete(struct Node *y){
if(y==nil)return;
y->pre->nex=y->nex;
y->nex->pre=y->pre;
}

int main(){
  struct Node *ans;
  int n,value,i;
  char order[10];

  nil=(struct Node*)malloc(sizeof(struct Node));
  nil->nex=nil;
  nil->pre=nil;

    scanf("%d",&n);

    for(i=0;i<n;i++){
      scanf("%s",order);

      if(strcmp(order,"insert")==0){
      scanf("%d",&value);
      Insert(value);
    }

      else if(strcmp(order,"delete")==0){
        scanf("%d",&value);
      Delete(listserch(value));
    }

      else if(strcmp(order,"deleteFirst")==0)
      Delete(nil->nex);

      else if(strcmp(order,"deleteLast")==0)
      Delete(nil->pre);

      else
      printf("miss order!!\n");

    }

    ans=nil->nex;
  while(ans->nex!=nil){
    printf("%d ",ans->key);
    ans=ans->nex;
  }

    printf("%d\n",ans->key);

    return 0;
}

