#include <stdio.h>
#include <stdlib.h>
typedef struct node_s node;

struct node_s{
  int key;
  node *pre;
  node *nx;
};

void insert(int);
void del(node *);
node *search(int);
node *h;
 
int main(){
  int i,n,x;
  char str[16];
  node *tsp;
     
  h = malloc(sizeof(node));
  h->key = -1;
  h->pre = h;
  h->nx = h;
  scanf("%d",&n);
 
  for (i=0;i<n;i++){
    scanf("%s", &str);
    if (str[0]=='i'){
      scanf("%d",&x);
      insert(x);
    }else if (str[0]=='d' && str[6]=='\0'){
      scanf("%d",&x);
      del(search(x));
    }else if (str[0]=='d' && str[6]=='F'){
    	del((h->nx));
    }else if (str[0]=='d' && str[6]=='L'){
    	del((h->pre));
    }
  }
  for (tsp = h->nx; tsp->nx->key != -1; tsp = tsp->nx)
    printf("%d " ,tsp->key);
    printf("%d\n" ,tsp->key);
  return 0;
}
void insert(int x){
  node *o = malloc(sizeof(node));
  o->key = x;
  o->nx = h->nx;
  o->pre = h;
  h->nx->pre = o;
  h->nx = o;
}
void del(node *n){
  if(n == NULL) return;
  n->pre->nx = n->nx;
  n->nx->pre = n->pre;
  free(n);
} 
node *search(int key){
  node *p;
  for (p=h->nx; p->key!=-1; p = p->nx){
    if (p->key == key){
      return p;
    }
  }
  return NULL;
}
