var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');

var n = lines.shift();

var q = [];
for (var i = 0; i < n; i++) {
	var arr = lines[i].split(' ');

	if (arr[0] == 'insert') {
		tmp = q;
		q = [arr[1] - 0];
		Array.prototype.push.apply(q, tmp);
	} else if (arr[0] == 'delete') {
		var idx = q.indexOf(arr[1] - 0);
		if (idx >= 0)
			q.splice(idx, 1);
	} else if (arr[0] == 'deleteFirst') {
		q.shift();
	} else if (arr[0] == 'deleteLast') {
		q.pop();
	}
}

var str = '';
str += q[0];
for (var i = 1, l = q.length; i < l; i++) {
	str += ' ' + q[i];
}
console.log(str);