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

#define N 2000000

void init();
void insert(int);
struct link * search(int);
void delete(int);
void print();

struct link{
	int key;
	struct link *back,*next;
};

struct link *nil;

void init(){
	nil = (struct link *)malloc(sizeof(struct link));
	nil->back = nil;
	nil->next = nil;
}

void insert(int key){
	struct link *node = (struct link *) malloc(sizeof(struct link));
	node->key = key;
	node->next = nil->next;
	nil->next= node;
	node->back = nil;
}

struct link * search(int key){
	struct link *t = nil->next;
	while(t->key != key)t = t->next;
	return t;
}

void delete(int key){
	struct link *x = search(key);
	x->back->next = x->next;
	x->next->back = x->back;
	free(x);
}

void print(){
	struct link *x;
	x = nil->next;
	while(1){
		if(x->next == nil){
			printf("%d",x->key);
			break;
		}
		printf("%d ",x->key);
		x = x->next;
	}
	printf("\n");
}

int main(){
	int key;
	int n,i;
	char ins[7];
	scanf("%d",&n);
	init();
	for(i=0;i<n;i++){
		scanf("%s%d",ins,&key);
		if(!strcmp(ins,"insert")){
			insert(key);
		}
		else if(!strcmp(ins,"delete")){
			delete(key);
		}
	}
	print();
	return 0;
}