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

struct node{
  int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

struct node nil;

int flag=0;
NodePointer last;

void insert(int key);
void delete(int key);
void deleteFirst();
void deleteLast();
void init(){
	nil.next=NULL;
	nil.prev=NULL;
}

int main(){
	int n, i, key;
	char com[12];
	NodePointer p;
  scanf("%d", &n);
  init();

 	for (i=0;i<n;i++){
		scanf("%s",com);
		if(strlen(com)>6){
			if(com[6]=='F') {
				deleteFirst();
			}else{
				deleteLast();
			}
		}else{
			scanf("%d",&key);
			if(com[0]=='i'){
				insert(key);
			}else{
				delete(key);
			}
		}
	}
	for(p=nil.next;p->next!=NULL;p=p->next){
		printf("%d ",p->key);
	}
	printf("%d\n",p->key);
	return 0;
}

void insert(int key){
	NodePointer x;
	flag++;
	x=(NodePointer)malloc(sizeof(struct node));
	x->key=key;
	x->next=nil.next;
	x->prev=&nil;
	nil.next=x;
	if(flag>1)x->next->prev=x;
	if(flag==1)last=x;
}

void delete(int key){
	NodePointer p,q;
	p=nil.next;
	while(p->key!=key){
		q=p;
		p=p->next;
	}
	if(p==last){
		deleteLast();
		last=q;
	}else if(p==nil.next){
		deleteFirst();
	}else{
		q->next=p->next;
		p->next->prev=q;
		free(p);
		flag--;
	}
}

void deleteFirst(){
	NodePointer p,q;
	p=nil.next;
	q=&nil;
	p->next->prev=q;
	q->next=p->next;
	free(p);
	flag--;
}

void deleteLast(){
	NodePointer p;
	p=last;
	p->prev->next=NULL;
	free(p);
	flag--;
	last=last->prev;
}