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

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

typedef struct node *NodePointer;
NodePointer nil;

NodePointer search(int k){
  NodePointer x;

  x=nil->next;
  while(x!=nil && x->key!=k){
    x=x->next;
  }

  return x;
}

void insert(int k){
  NodePointer x;

  x=malloc(sizeof(struct node));
  x->key=k;
  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;
}

void deleteNode(NodePointer x){
  x->prev->next=x->next;
  x->next->prev=x->prev;
}

void delete(int k){
  NodePointer x;

  x=search(k);
  if(x==nil) return;
  deleteNode(x);
}

void deleteFirst(){
  NodePointer x;

  x=nil->next;
  deleteNode(x);
}

void deleteLast(){
  NodePointer x;

  x=nil->prev;
  deleteNode(x);
}

int main(){
  int n,i,k,flag=1;
  char c[20];
  NodePointer x;

  nil=malloc(sizeof(struct node));
  nil->prev=nil;
  nil->next=nil;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",c);
    if(c[0]=='i'){
      scanf("%d",&k);
      insert(k);
    }else if(c[0]=='d'){
      if(strlen(c)>6){
	if(c[6]=='F') deleteFirst(); 
	  else if(c[6]=='L') deleteLast();
      }else{
	scanf("%d",&k);
	delete(k);
      }
    }
  }

  x=nil->next;
  while(1){
    if(x==nil) break;
    if(flag==0) printf(" ");
    printf("%d",x->key);
    x=x->next;
    flag=0;
  }
  printf("\n");

  return 0;
}