#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int head;
int tail;
typedef struct{
  char name[11];
  int num;
}Q;
void enqueue(Q *a);
void dequeue(Q *a);
int main()
{
  int n,m,k=0,i,sum=0,u,x=0;
  head=0;
  scanf("%d",&n);
  tail=n-1;
  Q q[n];
  int arr[n];
  for(i=0;i<n;i++){
    arr[i]=0;
    scanf("%s",q[i].name);
    if(strcmp("deleteFirst",q[i].name)==0){
      k=k-1;
     continue;
    }else if(strcmp("deleteLast",q[i].name)==0){
      dequeue(q);
     continue;
    }
    scanf("%d",&q[i].num);
    if(strcmp("insert",q[i].name)==0){
    arr[k]=q[i].num;
    k++;
    }else if(strcmp("delete",q[i].name)==0){
      m++;
      for(u=0;u<k;u++){
        if(arr[u]==q[i].num){
          arr[u]=0;
          if(u==head)dequeue(q);
          if(u==k-1)enqueue(q);
          break;
        }
      }
    }
  }
  for(i=k-1;i>=head;i--){
    if(arr[i]==0)continue;
    if(i!=k-1 || x!=0)printf(" ");
    printf("%d",arr[i]);
    x++;
  }
  printf("\n");
  return 0;
}
void enqueue(Q *a){
  tail=tail-1;
}
void dequeue(Q *a){
  head=head+1;
}
