#include <stdio.h>
#include <string.h>
#define MAX 20000

typedef struct pp{
  char command[100];
  int n;
}P;

void insert(int);
void delete(int);
void deleteFirst(void);
void deleteLast(void);

int Z[MAX];
int head,tail;

int main(){
  int n,i;
  P X[MAX];

  scanf("%d",&n);
  head = 1;
  tail = 1;

  for(i = 1; i <= n; i++){
    scanf("%s",X[i].command);
    if(strcmp("deleteFirst",X[i].command) != 0 && strcmp("deleteLast",X[i].command) != 0) scanf("%d",&X[i].n);
  }

  for(i = 1; i <= n; i++){
    if(strcmp("insert",X[i].command) == 0){
      insert(X[i].n);
    }
    else {
      if(strcmp("delete",X[i].command) == 0){
	delete(X[i].n);
      }
      else{
	if(strcmp("deleteFirst",X[i].command) == 0) deleteFirst();
	else{
	  if(strcmp("deleteLast",X[i].command) == 0){
	    deleteLast();
	  }
	}
      }
    }
  }
 
  for(i = 1; i < tail; i++) printf("%d ",Z[i]);
  printf("\n");

  return 0;
}

void insert(int n){
  int i;
  i = tail;
  while(i != head){
  Z[i] = Z[i-1];
  i--;
  }
  tail++;
  Z[head] = n;
}

void delete(int n){
  int i,j;
  int z;
  for(i = 1; i < tail; i++){
    if(n == Z[i]){
      z = Z[i];
      j = i;
      while(j+1 != tail){
      Z[j] = Z[j+1];
      j++;
      }
      tail--;
      break;
    }
  }
}

void deleteFirst(){
  int z,i;
  z = Z[head];
  i = head;
  while(Z[i+1] != '\0'){
  Z[i] = Z[i+1];
  i++;
  }
  tail--;
}

void deleteLast(){
  int z;
  z = Z[tail-1];
  tail--;
}