import std.stdio, std.algorithm, std.conv, std.string, std.range;
import std.container;

void main(string[] args) {
    auto dlist = DList!int();

    int n = readln.chomp.to!int;
    foreach (i; 0..n) {
        string op = readln.chomp;

        if (op[0..7] == "insert ") {
            dlist.insertFront(op[7..$].to!int);
        } else if (op[0..7] == "delete ") {
            auto range = dlist[];
            for ( ; !range.empty; range.popFront()) {
                if (range.front == op[7..$].to!int) {
                    dlist.stableLinearRemove(take(range, 1));
                    break;
                }
            }
        } else if (op == "deleteFirst") {
            dlist.removeFront;
        } else if (op == "deleteLast") {
            dlist.removeBack;
        }
    }

    dlist[].map!(to!string).join(" ").writeln;
}