var stdin = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = stdin.split('\n');
lines.shift();
var list = [];
lines.forEach(function(line) {
  if (line !== '') {
    var command = line.trim().split(' ');
    if (command[0] === 'insert') {
      list.unshift(command[1]);
    } else if (command[0] === 'delete') {
      var index = list.indexOf(command[1]);
      if (index >= 0) {
        list.splice(index, 1);
      }
    } else if (command[0] === 'deleteFirst') {
      list.shift();
    } else if (command[0] === 'deleteLast') {
      list.pop();
    }
  }
});
console.log(list.join(' '));