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

struct P{
  int key;
  struct P *prev,*next;
};
typedef struct P* node;
node F,L;

void insert(int x) {
  node z=F->next;
  node v=malloc(sizeof(struct P));
  v->key=x;
  F->next=v;
  v->prev=F;
  v->next=z;
  z->prev=v;
}

void delete(int x) {
  node z=F;
  while(z->key!=x && z!=L) z=z->next;
  node l=z->prev,r=z->next;
  l->next=r;
  r->prev=l;
}

void deleteF() {
  node z=F->next->next;
  F->next=z;
  z->prev=F;
}

void deleteL() {
  node z=L->prev->prev;
  L->prev=z;
  z->next=L;
}

int main() {
  int n;
  scanf("%d",&n);
  char c[10];
  int x;
  F=malloc(sizeof(struct P));
  L=malloc(sizeof(struct P));
  F->next=L;F->prev=F;
  L->prev=F;L->next=L;
  while(n--) {
    scanf("%s",c);
    if(c[0]=='i') {
      scanf("%d",&x);
      insert(x);
    } else if(c[6]=='F') deleteF();
    else if(c[6]=='L') deleteL();
    else {
      scanf("%d",&x);
      delete(x);
    }
  }
  node z=F->next;
  while(z!=L) {
    if(z!=F->next) printf(" ");
    printf("%d",z->key);
    z=z->next;
  }
  printf("\n");
  return 0;
}




  

 

