#include <stdio.h>
#include<stdlib.h>
#define N 2000000

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 deleteFirst() {
  node z = F->next->next;
  F->next = z;
  z->prev = F;
}

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

int main() {
  int n;
  char c[10];
  int x;

  scanf("%d",&n);
  if(n > N)exit(1);

  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') deleteFirst();
    else if(c[6] == 'L') deleteLast();
    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;
}

