(function(input) {
    var p = input.split('\n');
    var n = Number(p.shift());
    var cs = p.slice(0, n);
    var l = [];
    cs.forEach(function(e) {
        l = command(l, e);
    });
    console.log(l.join(' '));
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

function command(l, c) {
    var a = c.split(' ');
    var com = a.shift();
    var arg = Number(a.shift());
    switch (com) {
        case 'insert':
            l.unshift(arg);
            break;
        case 'delete':
            var i = l.indexOf(arg);
            if (i >= 0) {
                l = l.slice(0, i).concat(l.slice(i + 1, l.length));
            }
            break;
        case 'deleteFirst':
            l.shift();
            break;
        case 'deleteLast':
            l.pop();
            break;
    }
    return l;
}