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

#define BUF_SIZE 100

typedef struct list_tag{
  struct list_tag *pre;
  struct list_tag *post;
  long val;
}list;

void print_list(list *p)
{
  list *now;

  now = p;

  do{
    printf("%ld", now->val);
    now = now->post;
    if(now != p)
      printf(" ");
  }while(now != p);

  printf("\n");

  return;
}

list *create(long val)
{
  list *pl;

  pl = (list *)malloc(sizeof(list));
  pl->pre = pl;
  pl->post = pl;
  pl->val = val;

  return pl;
}

list *insert(list* p1, long val)
{
  list *p0;
  p0 = create(val);
  if(p1 != NULL){
    p0->pre = p1->pre;
    p0->post = p1;
    (p1->pre)->post = p0;
    p1->pre = p0;
  }
  return p0;
}

list *delete(list *p, long val)
{
  list *now;

  now = p;

  do{
    if(now->val == val){
      if(now == p) p = p->post;
      (now->post)->pre = now->pre;
      (now->pre)->post = now->post;
      break;
    }
    now = now->post;
  }while(p != now);

  return p;
}

int main(void)
{
  long n, i;
  list *lst = NULL;

  scanf("%8ld", &n);
  for(i = 0; i < n; i++){
    char buf[BUF_SIZE];
    long val;

    fgets(buf, BUF_SIZE, stdin);

    if(buf[0] == 'i'){
      sscanf(buf, "%s %ld", buf, &val);
      lst = insert(lst, val);
    }else if(buf[7] == ' '){
      sscanf(buf, "%s %ld", buf, &val);
      lst = delete(lst, val);
    }else if(buf[7] == 'F'){
      lst = delete(lst, lst->val);
    }else if(buf[7] == 'L'){
      lst = delete(lst->pre, (lst->pre)->val);
    }else{
      assert(0);
    }
  }

  print_list(lst);

  return 0;
}