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

struct node {
  int number;
  struct node *next,*fir;
};

struct node *nil;

struct node* listsearch(int);

void initem();
void print();
void deletenode(struct node *);
void deleteFirst();
void deleteLast();
void deletenum();
void insert(int);

struct node* listsearch(int number)
{
  struct node *x = nil->next;

  while(x != nil && x->number!= number) 
    x = x->next;

  return x;

}

void initem()
{
  nil = (struct node*)malloc(sizeof(struct node));
  nil->next = nil;
  nil->fir = nil;
}

void print()
{
  int isfirst = 0;
  struct node *y = nil->next;

  while(1) {
    if(y == nil)
      break;

    if(isfirst++ > 0)
      printf(" ");

    printf("%d",y->number);

    y = y->next;
  }
  printf("\n");

}

void deletenode(struct node *z)
{
  if(z == nil)
    return;

  z->fir->next = z->next;
  z->next->fir =  z->fir;

  free(z);
}

void deleteFirst()
{
  deletenode(nil->next);
}

void deleteLast()
{
  deletenode(nil->fir);
}

void deletenum(int number)
{
  deletenode(listsearch(number));
}

void insert(int number)
{
  struct node *r = (struct node*)malloc(sizeof(struct node));
  r->number = number;
  r->next = nil->next;
  nil->next->fir= r;
  nil->next = r;
  r->fir= nil;
}

int main()
{
  int n,i,number,size=0,a=0,b=0;
  char c[20];

  scanf("%d",&n);

  initem();
 
  for(i=0;i<n;i++) {

    scanf("%s%d",c,&number);

    if(c[0] == 'i') {
      insert(number);
      a++;
      size++;
    }
    else if(c[0] == 'd') {
      if(strlen(c) > 6) {
	if(c[6] == 'F') 
	  deleteFirst();
	  else if(c[6] == 'L')
	  deleteLast();
	}
    else{
	  deletenum(number);
	  b++;
      }
      size--;
    }
  }

  print();

  return 0;
}


