# -*- coding:utf-8 -*-
import sys


class Cell(object):
    __slots__ = ["value", "pre", "next"]

    def __init__(self, value=None, pre=None, _next=None):
        if pre is None and _next is None:
            self.value = None
            self.pre = self
            self.next = self
        else:
            self.value = value
            self.pre = pre
            self.next = _next


class MyList(object):
    def __init__(self):
        self._nil = Cell()

    def insert(self, value):
        self._nil.next = Cell(value, self._nil, self._nil.next)
        self._nil.next.next.pre = self._nil.next

    def delete(self, value):
        self._delete_to(self._search(value))

    def delete_first(self):
        self._delete_to(self._nil.next)

    def delete_last(self):
        self._delete_to(self._nil.pre)

    def toList(self):
        gen = self._val_generator()
        return [val for val in gen()]

    def _val_generator(self):
        def gen():
            current = self._nil.next
            while current is not self._nil:
                yield current.value
                current = current.next
        return gen

    def _delete_to(self, cell):
        if cell is not self._nil:
            cell.next.pre = cell.pre
            cell.pre.next = cell.next

    def _search(self, value):
        current = self._nil.next
        while current is not self._nil and current.value != value:
            current = current.next
        return current


def doubly_inked_list(commands):
    lst = MyList()
    for command in commands:
        if command[0] == "insert":
            lst.insert(command[1])
        elif command[0] == "delete":
            lst.delete(command[1])
        elif command[0] == "deleteFirst":
            lst.delete_first()
        elif command[0] == "deleteLast":
            lst.delete_last()
        else:
            raise ValueError
    return lst.toList()


if __name__ == "__main__":
    commands = [val.split() for val in sys.stdin.read().splitlines()]
    pop = commands.pop(0)
    print(" ".join(doubly_inked_list(commands))) import sys sys class Cell(object):
    __slots__ = ["value", "pre", "next"]

    def __init__(self, value=None, pre=None, _next=None):
        if pre is None and _next is None:
            self.value = None
            self.pre = self
            self.next = self
        else:
            self.value = value
            self.pre = pre
            self.next = _next Cell __slots__ = ["value", "pre", "next"] __slots__ ["value", "pre", "next"] "value" "pre" "next" def __init__(self, value=None, pre=None, _next=None):
        if pre is None and _next is None:
            self.value = None
            self.pre = self
            self.next = self
        else:
            self.value = value
            self.pre = pre
            self.next = _next __init__ if pre is None and _next is None:
            self.value = None
            self.pre = self
            self.next = self
        else:
            self.value = value
            self.pre = pre
            self.next = _next pre is None and _next is None pre is None pre None _next is None _next None self.value = None self.value self value None self.pre = self self.pre self pre self self.next = self self.next self next self self.value = value self.value self value value self.pre = pre self.pre self pre pre self.next = _next self.next self next _next self self value=None value None pre=None pre None _next=None _next None object class MyList(object):
    def __init__(self):
        self._nil = Cell()

    def insert(self, value):
        self._nil.next = Cell(value, self._nil, self._nil.next)
        self._nil.next.next.pre = self._nil.next

    def delete(self, value):
        self._delete_to(self._search(value))

    def delete_first(self):
        self._delete_to(self._nil.next)

    def delete_last(self):
        self._delete_to(self._nil.pre)

    def toList(self):
        gen = self._val_generator()
        return [val for val in gen()]

    def _val_generator(self):
        def gen():
            current = self._nil.next
            while current is not self._nil:
                yield current.value
                current = current.next
        return gen

    def _delete_to(self, cell):
        if cell is not self._nil:
            cell.next.pre = cell.pre
            cell.pre.next = cell.next

    def _search(self, value):
        current = self._nil.next
        while current is not self._nil and current.value != value:
            current = current.next
        return current MyList def __init__(self):
        self._nil = Cell()

     __init__ self._nil = Cell() self._nil self _nil Cell() Cell self self def insert(self, value):
        self._nil.next = Cell(value, self._nil, self._nil.next)
        self._nil.next.next.pre = self._nil.next

     insert self._nil.next = Cell(value, self._nil, self._nil.next) self._nil.next self._nil self _nil next Cell(value, self._nil, self._nil.next) Cell value self._nil self _nil self._nil.next self._nil self _nil next self._nil.next.next.pre = self._nil.next self._nil.next.next.pre self._nil.next.next self._nil.next self._nil self _nil next next pre self._nil.next self._nil self _nil next self self value value def delete(self, value):
        self._delete_to(self._search(value))

     delete self._delete_to(self._search(value)) self._delete_to self _delete_to self._search(value) self._search self _search value self self value value def delete_first(self):
        self._delete_to(self._nil.next)

     delete_first self._delete_to(self._nil.next) self._delete_to self _delete_to self._nil.next self._nil self _nil next self self def delete_last(self):
        self._delete_to(self._nil.pre)

     delete_last self._delete_to(self._nil.pre) self._delete_to self _delete_to self._nil.pre self._nil self _nil pre self self def toList(self):
        gen = self._val_generator()
        return [val for val in gen()]

     toList gen = self._val_generator() gen self._val_generator() self._val_generator self _val_generator val for val in gen() for val in gen() val gen() gen for val in gen() val return [val for val in gen()] [val for val in gen()] self self def _val_generator(self):
        def gen():
            current = self._nil.next
            while current is not self._nil:
                yield current.value
                current = current.next
        return gen

     _val_generator def gen():
            current = self._nil.next
            while current is not self._nil:
                yield current.value
                current = current.next
         gen current = self._nil.next current self._nil.next self._nil self _nil next while current is not self._nil:
                yield current.value
                current = current.next
         current is not self._nil current self._nil self _nil yield current.value current.value current value current = current.next current current.next current next return gen gen self self def _delete_to(self, cell):
        if cell is not self._nil:
            cell.next.pre = cell.pre
            cell.pre.next = cell.next

     _delete_to if cell is not self._nil:
            cell.next.pre = cell.pre
            cell.pre.next = cell.next

     cell is not self._nil cell self._nil self _nil cell.next.pre = cell.pre cell.next.pre cell.next cell next pre cell.pre cell pre cell.pre.next = cell.next cell.pre.next cell.pre cell pre next cell.next cell next self self cell cell def _search(self, value):
        current = self._nil.next
        while current is not self._nil and current.value != value:
            current = current.next
        return current _search current = self._nil.next current self._nil.next self._nil self _nil next while current is not self._nil and current.value != value:
            current = current.next
         current is not self._nil and current.value != value current is not self._nil current self._nil self _nil current.value != value current.value current value value current = current.next current current.next current next return current current self self value value object def doubly_inked_list(commands):
    lst = MyList()
    for command in commands:
        if command[0] == "insert":
            lst.insert(command[1])
        elif command[0] == "delete":
            lst.delete(command[1])
        elif command[0] == "deleteFirst":
            lst.delete_first()
        elif command[0] == "deleteLast":
            lst.delete_last()
        else:
            raise ValueError
    return lst.toList() doubly_inked_list lst = MyList() lst MyList() MyList for command in commands:
        if command[0] == "insert":
            lst.insert(command[1])
        elif command[0] == "delete":
            lst.delete(command[1])
        elif command[0] == "deleteFirst":
            lst.delete_first()
        elif command[0] == "deleteLast":
            lst.delete_last()
        else:
            raise ValueError
     command commands if command[0] == "insert":
            lst.insert(command[1])
        elif command[0] == "delete":
            lst.delete(command[1])
        elif command[0] == "deleteFirst":
            lst.delete_first()
        elif command[0] == "deleteLast":
            lst.delete_last()
        else:
            raise ValueError
     command[0] == "insert" command[0] command 0 "insert" lst.insert(command[1]) lst.insert lst insert command[1] command 1 elif command[0] == "delete":
            lst.delete(command[1])
         command[0] == "delete" command[0] command 0 "delete" lst.delete(command[1]) lst.delete lst delete command[1] command 1 elif command[0] == "deleteFirst":
            lst.delete_first()
         command[0] == "deleteFirst" command[0] command 0 "deleteFirst" lst.delete_first() lst.delete_first lst delete_first elif command[0] == "deleteLast":
            lst.delete_last()
         command[0] == "deleteLast" command[0] command 0 "deleteLast" lst.delete_last() lst.delete_last lst delete_last raise ValueError ValueError return lst.toList() lst.toList() lst.toList lst toList commands commands if __name__ == "__main__":
    commands = [val.split() for val in sys.stdin.read().splitlines()]
    pop = commands.pop(0)
    print(" ".join(doubly_inked_list(commands))) __name__ == "__main__" __name__ "__main__" val.split() for val in sys.stdin.read().splitlines() for val in sys.stdin.read().splitlines() val sys.stdin.read().splitlines() sys.stdin.read().splitlines sys.stdin.read() sys.stdin.read sys.stdin sys stdin read splitlines for val in sys.stdin.read().splitlines() val.split() val.split val split commands = [val.split() for val in sys.stdin.read().splitlines()] commands [val.split() for val in sys.stdin.read().splitlines()] pop = commands.pop(0) pop commands.pop(0) commands.pop commands pop 0 print(" ".join(doubly_inked_list(commands))) print " ".join(doubly_inked_list(commands)) " ".join " " join doubly_inked_list(commands) doubly_inked_list commands commands = [val.split() for val in sys.stdin.read().splitlines()] [val.split() for val in sys.stdin.read().splitlines()] commands def doubly_inked_list(commands):
    lst = MyList()
    for command in commands:
        if command[0] == "insert":
            lst.insert(command[1])
        elif command[0] == "delete":
            lst.delete(command[1])
        elif command[0] == "deleteFirst":
            lst.delete_first()
        elif command[0] == "deleteLast":
            lst.delete_last()
        else:
            raise ValueError
    return lst.toList() def doubly_inked_list(commands):
    lst = MyList()
    for command in commands:
        if command[0] == "insert":
            lst.insert(command[1])
        elif command[0] == "delete":
            lst.delete(command[1])
        elif command[0] == "deleteFirst":
            lst.delete_first()
        elif command[0] == "deleteLast":
            lst.delete_last()
        else:
            raise ValueError
    return lst.toList() doubly_inked_list pop = commands.pop(0) commands.pop(0) pop class MyList(object):
    def __init__(self):
        self._nil = Cell()

    def insert(self, value):
        self._nil.next = Cell(value, self._nil, self._nil.next)
        self._nil.next.next.pre = self._nil.next

    def delete(self, value):
        self._delete_to(self._search(value))

    def delete_first(self):
        self._delete_to(self._nil.next)

    def delete_last(self):
        self._delete_to(self._nil.pre)

    def toList(self):
        gen = self._val_generator()
        return [val for val in gen()]

    def _val_generator(self):
        def gen():
            current = self._nil.next
            while current is not self._nil:
                yield current.value
                current = current.next
        return gen

    def _delete_to(self, cell):
        if cell is not self._nil:
            cell.next.pre = cell.pre
            cell.pre.next = cell.next

    def _search(self, value):
        current = self._nil.next
        while current is not self._nil and current.value != value:
            current = current.next
        return current class MyList(object):
    def __init__(self):
        self._nil = Cell()

    def insert(self, value):
        self._nil.next = Cell(value, self._nil, self._nil.next)
        self._nil.next.next.pre = self._nil.next

    def delete(self, value):
        self._delete_to(self._search(value))

    def delete_first(self):
        self._delete_to(self._nil.next)

    def delete_last(self):
        self._delete_to(self._nil.pre)

    def toList(self):
        gen = self._val_generator()
        return [val for val in gen()]

    def _val_generator(self):
        def gen():
            current = self._nil.next
            while current is not self._nil:
                yield current.value
                current = current.next
        return gen

    def _delete_to(self, cell):
        if cell is not self._nil:
            cell.next.pre = cell.pre
            cell.pre.next = cell.next

    def _search(self, value):
        current = self._nil.next
        while current is not self._nil and current.value != value:
            current = current.next
        return current MyList class Cell(object):
    __slots__ = ["value", "pre", "next"]

    def __init__(self, value=None, pre=None, _next=None):
        if pre is None and _next is None:
            self.value = None
            self.pre = self
            self.next = self
        else:
            self.value = value
            self.pre = pre
            self.next = _next class Cell(object):
    __slots__ = ["value", "pre", "next"]

    def __init__(self, value=None, pre=None, _next=None):
        if pre is None and _next is None:
            self.value = None
            self.pre = self
            self.next = self
        else:
            self.value = value
            self.pre = pre
            self.next = _next Cell
# -*- coding:utf-8 -*-
import sys


class Cell(object):
    __slots__ = ["value", "pre", "next"]

    def __init__(self, value=None, pre=None, _next=None):
        if pre is None and _next is None:
            self.value = None
            self.pre = self
            self.next = self
        else:
            self.value = value
            self.pre = pre
            self.next = _next


class MyList(object):
    def __init__(self):
        self._nil = Cell()

    def insert(self, value):
        self._nil.next = Cell(value, self._nil, self._nil.next)
        self._nil.next.next.pre = self._nil.next

    def delete(self, value):
        self._delete_to(self._search(value))

    def delete_first(self):
        self._delete_to(self._nil.next)

    def delete_last(self):
        self._delete_to(self._nil.pre)

    def toList(self):
        gen = self._val_generator()
        return [val for val in gen()]

    def _val_generator(self):
        def gen():
            current = self._nil.next
            while current is not self._nil:
                yield current.value
                current = current.next
        return gen

    def _delete_to(self, cell):
        if cell is not self._nil:
            cell.next.pre = cell.pre
            cell.pre.next = cell.next

    def _search(self, value):
        current = self._nil.next
        while current is not self._nil and current.value != value:
            current = current.next
        return current


def doubly_inked_list(commands):
    lst = MyList()
    for command in commands:
        if command[0] == "insert":
            lst.insert(command[1])
        elif command[0] == "delete":
            lst.delete(command[1])
        elif command[0] == "deleteFirst":
            lst.delete_first()
        elif command[0] == "deleteLast":
            lst.delete_last()
        else:
            raise ValueError
    return lst.toList()


if __name__ == "__main__":
    commands = [val.split() for val in sys.stdin.read().splitlines()]
    pop = commands.pop(0)
    print(" ".join(doubly_inked_list(commands)))