var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
Arr.shift();
var list=[];
for(var i=0;i<Arr.length;i++){
var arr=Arr[i].split(" ");
var a=arr[0];
var b=arr[1]-0;
if(a=="insert"){list.unshift(b);}
else if(a=="delete"){
   for(var j=0;j<list.length;j++){
   if(b==list[j]){list.splice(j,1);break;}
   }
}
else if(a=="deleteFirst"){list.shift();}
else if(a=="deleteLast"){list.pop();}
}
console.log(list.join(" "));