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

int main(){
	int n;
	char command[11];
	int num;
	
	int N[2000000];
	
	int i,j,k,l;
	
	int D;
	
	scanf("%d",&n);
	D = n;
	for(i = 0,j = 0;i < D;i++){
		scanf("%s",&command);
		if(strcmp(command,"deleteFirst") != 0&&strcmp(command,"deleteLast") != 0){
			scanf("%d",&num);
		
			if(strcmp(command,"insert") == 0){
				N[j] = num;
				j++;
			}else if(strcmp(command,"delete") == 0){
				for(l = 0;l < j;l++){
					if(N[l] == num)break;
				}
				for(k = l;k < j-1;k++){
					N[k] = N[k+1];
				}		
				j--;
			}
		}else if(strcmp(command,"deleteLast") == 0){
			N[j - 1] = -1;
			j--;
		}else if(strcmp(command,"deleteFirst") == 0){
			for(k = 0;k < j-1;k++){
				N[k] = N[k+1];
			}
			j--;
		}
	}
	
	
	for(i = j-1;i >= 1;i--){
		printf("%d ",N[i]);
	}
	printf("%d",N[0]);
	printf("\n");
	return 0;
}
	