import sys


class DoubleLinkedList:
    class Node:
        def __init__(self, value=None, prev=None, _next=None):
            self.value = value
            self.prev = prev
            self.next = _next

    def __init__(self):
        self.head = self.Node()
        self.tail = self.Node()
        self.head.next = self.tail
        self.tail.prev = self.head

    def insert(self, v):
        head = self.head
        node = self.Node(v, head, head.next)
        head.next.prev = node
        head.next = node

    def delete(self, node):
        if node in (self.head, self.tail):
            return
        else:
            node.prev.next, node.next.prev = node.next, node.prev

    def delete_first(self):
        self.delete(self.head.next)

    def delete_last(self):
        self.delete(self.tail.prev)

    def delete_first_value(self, v):
        node = self.find(v, self.head)
        if node is not None:
            self.delete(node)

    def find(self, v, cur=None):
        if cur is None:
            cur = self.head

        while cur != self.tail:
            cur = cur.next
            if cur.value == v:
                return cur

        return None

    def __str__(self):
        cur = self.head.next
        vs = ''
        while cur != self.tail:
            vs += cur.value
            cur = cur.next
            if cur != self.tail:
                vs += ' '

        return vs


def run():
    steps = int(input())  # flake8: noqa
    dl = DoubleLinkedList()

    for command in sys.stdin:
        if command.startswith('insert'):
            dl.insert(command[7:-1])
        elif command.startswith('deleteFirst'):
            dl.delete_first()
        elif command.startswith('deleteLast'):
            dl.delete_last()
        elif command.startswith('delete'):
            dl.delete_first_value(command[7:-1])
        else:
            raise ValueError()

    print(dl)


if __name__ == '__main__':
    run()
 import sys sys class DoubleLinkedList:
    class Node:
        def __init__(self, value=None, prev=None, _next=None):
            self.value = value
            self.prev = prev
            self.next = _next

    def __init__(self):
        self.head = self.Node()
        self.tail = self.Node()
        self.head.next = self.tail
        self.tail.prev = self.head

    def insert(self, v):
        head = self.head
        node = self.Node(v, head, head.next)
        head.next.prev = node
        head.next = node

    def delete(self, node):
        if node in (self.head, self.tail):
            return
        else:
            node.prev.next, node.next.prev = node.next, node.prev

    def delete_first(self):
        self.delete(self.head.next)

    def delete_last(self):
        self.delete(self.tail.prev)

    def delete_first_value(self, v):
        node = self.find(v, self.head)
        if node is not None:
            self.delete(node)

    def find(self, v, cur=None):
        if cur is None:
            cur = self.head

        while cur != self.tail:
            cur = cur.next
            if cur.value == v:
                return cur

        return None

    def __str__(self):
        cur = self.head.next
        vs = ''
        while cur != self.tail:
            vs += cur.value
            cur = cur.next
            if cur != self.tail:
                vs += ' '

        return vs DoubleLinkedList class Node:
        def __init__(self, value=None, prev=None, _next=None):
            self.value = value
            self.prev = prev
            self.next = _next

     Node def __init__(self, value=None, prev=None, _next=None):
            self.value = value
            self.prev = prev
            self.next = _next

     __init__ self.value = value self.value self value value self.prev = prev self.prev self prev prev self.next = _next self.next self next _next self self value=None value None prev=None prev None _next=None _next None def __init__(self):
        self.head = self.Node()
        self.tail = self.Node()
        self.head.next = self.tail
        self.tail.prev = self.head

     __init__ self.head = self.Node() self.head self head self.Node() self.Node self Node self.tail = self.Node() self.tail self tail self.Node() self.Node self Node self.head.next = self.tail self.head.next self.head self head next self.tail self tail self.tail.prev = self.head self.tail.prev self.tail self tail prev self.head self head self self def insert(self, v):
        head = self.head
        node = self.Node(v, head, head.next)
        head.next.prev = node
        head.next = node

     insert head = self.head head self.head self head node = self.Node(v, head, head.next) node self.Node(v, head, head.next) self.Node self Node v head head.next head next head.next.prev = node head.next.prev head.next head next prev node head.next = node head.next head next node self self v v def delete(self, node):
        if node in (self.head, self.tail):
            return
        else:
            node.prev.next, node.next.prev = node.next, node.prev

     delete if node in (self.head, self.tail):
            return
        else:
            node.prev.next, node.next.prev = node.next, node.prev

     node in (self.head, self.tail) node (self.head, self.tail) self.head self head self.tail self tail return node.prev.next, node.next.prev = node.next, node.prev node.prev.next node.prev node prev next node.next node next node.next.prev node.next node next prev node.prev node prev self self node node def delete_first(self):
        self.delete(self.head.next)

     delete_first self.delete(self.head.next) self.delete self delete self.head.next self.head self head next self self def delete_last(self):
        self.delete(self.tail.prev)

     delete_last self.delete(self.tail.prev) self.delete self delete self.tail.prev self.tail self tail prev self self def delete_first_value(self, v):
        node = self.find(v, self.head)
        if node is not None:
            self.delete(node)

     delete_first_value node = self.find(v, self.head) node self.find(v, self.head) self.find self find v self.head self head if node is not None:
            self.delete(node)

     node is not None node None self.delete(node) self.delete self delete node self self v v def find(self, v, cur=None):
        if cur is None:
            cur = self.head

        while cur != self.tail:
            cur = cur.next
            if cur.value == v:
                return cur

        return None

     find if cur is None:
            cur = self.head

         cur is None cur None cur = self.head cur self.head self head while cur != self.tail:
            cur = cur.next
            if cur.value == v:
                return cur

         cur != self.tail cur self.tail self tail cur = cur.next cur cur.next cur next if cur.value == v:
                return cur

         cur.value == v cur.value cur value v return cur cur return None None self self v v cur=None cur None def __str__(self):
        cur = self.head.next
        vs = ''
        while cur != self.tail:
            vs += cur.value
            cur = cur.next
            if cur != self.tail:
                vs += ' '

        return vs __str__ cur = self.head.next cur self.head.next self.head self head next vs = '' vs '' while cur != self.tail:
            vs += cur.value
            cur = cur.next
            if cur != self.tail:
                vs += ' '

         cur != self.tail cur self.tail self tail vs += cur.value vs cur.value cur value cur = cur.next cur cur.next cur next if cur != self.tail:
                vs += ' '

         cur != self.tail cur self.tail self tail vs += ' ' vs ' ' return vs vs self self def run():
    steps = int(input())  # flake8: noqa
    dl = DoubleLinkedList()

    for command in sys.stdin:
        if command.startswith('insert'):
            dl.insert(command[7:-1])
        elif command.startswith('deleteFirst'):
            dl.delete_first()
        elif command.startswith('deleteLast'):
            dl.delete_last()
        elif command.startswith('delete'):
            dl.delete_first_value(command[7:-1])
        else:
            raise ValueError()

    print(dl) run steps = int(input()) steps int(input()) int input() input dl = DoubleLinkedList() dl DoubleLinkedList() DoubleLinkedList for command in sys.stdin:
        if command.startswith('insert'):
            dl.insert(command[7:-1])
        elif command.startswith('deleteFirst'):
            dl.delete_first()
        elif command.startswith('deleteLast'):
            dl.delete_last()
        elif command.startswith('delete'):
            dl.delete_first_value(command[7:-1])
        else:
            raise ValueError()

     command sys.stdin sys stdin if command.startswith('insert'):
            dl.insert(command[7:-1])
        elif command.startswith('deleteFirst'):
            dl.delete_first()
        elif command.startswith('deleteLast'):
            dl.delete_last()
        elif command.startswith('delete'):
            dl.delete_first_value(command[7:-1])
        else:
            raise ValueError()

     command.startswith('insert') command.startswith command startswith 'insert' dl.insert(command[7:-1]) dl.insert dl insert command[7:-1] command 7:-1 7 -1 elif command.startswith('deleteFirst'):
            dl.delete_first()
         command.startswith('deleteFirst') command.startswith command startswith 'deleteFirst' dl.delete_first() dl.delete_first dl delete_first elif command.startswith('deleteLast'):
            dl.delete_last()
         command.startswith('deleteLast') command.startswith command startswith 'deleteLast' dl.delete_last() dl.delete_last dl delete_last elif command.startswith('delete'):
            dl.delete_first_value(command[7:-1])
         command.startswith('delete') command.startswith command startswith 'delete' dl.delete_first_value(command[7:-1]) dl.delete_first_value dl delete_first_value command[7:-1] command 7:-1 7 -1 raise ValueError() ValueError() ValueError print(dl) print dl if __name__ == '__main__':
    run() __name__ == '__main__' __name__ '__main__' run() run def run():
    steps = int(input())  # flake8: noqa
    dl = DoubleLinkedList()

    for command in sys.stdin:
        if command.startswith('insert'):
            dl.insert(command[7:-1])
        elif command.startswith('deleteFirst'):
            dl.delete_first()
        elif command.startswith('deleteLast'):
            dl.delete_last()
        elif command.startswith('delete'):
            dl.delete_first_value(command[7:-1])
        else:
            raise ValueError()

    print(dl) def run():
    steps = int(input())  # flake8: noqa
    dl = DoubleLinkedList()

    for command in sys.stdin:
        if command.startswith('insert'):
            dl.insert(command[7:-1])
        elif command.startswith('deleteFirst'):
            dl.delete_first()
        elif command.startswith('deleteLast'):
            dl.delete_last()
        elif command.startswith('delete'):
            dl.delete_first_value(command[7:-1])
        else:
            raise ValueError()

    print(dl) run class DoubleLinkedList:
    class Node:
        def __init__(self, value=None, prev=None, _next=None):
            self.value = value
            self.prev = prev
            self.next = _next

    def __init__(self):
        self.head = self.Node()
        self.tail = self.Node()
        self.head.next = self.tail
        self.tail.prev = self.head

    def insert(self, v):
        head = self.head
        node = self.Node(v, head, head.next)
        head.next.prev = node
        head.next = node

    def delete(self, node):
        if node in (self.head, self.tail):
            return
        else:
            node.prev.next, node.next.prev = node.next, node.prev

    def delete_first(self):
        self.delete(self.head.next)

    def delete_last(self):
        self.delete(self.tail.prev)

    def delete_first_value(self, v):
        node = self.find(v, self.head)
        if node is not None:
            self.delete(node)

    def find(self, v, cur=None):
        if cur is None:
            cur = self.head

        while cur != self.tail:
            cur = cur.next
            if cur.value == v:
                return cur

        return None

    def __str__(self):
        cur = self.head.next
        vs = ''
        while cur != self.tail:
            vs += cur.value
            cur = cur.next
            if cur != self.tail:
                vs += ' '

        return vs class DoubleLinkedList:
    class Node:
        def __init__(self, value=None, prev=None, _next=None):
            self.value = value
            self.prev = prev
            self.next = _next

    def __init__(self):
        self.head = self.Node()
        self.tail = self.Node()
        self.head.next = self.tail
        self.tail.prev = self.head

    def insert(self, v):
        head = self.head
        node = self.Node(v, head, head.next)
        head.next.prev = node
        head.next = node

    def delete(self, node):
        if node in (self.head, self.tail):
            return
        else:
            node.prev.next, node.next.prev = node.next, node.prev

    def delete_first(self):
        self.delete(self.head.next)

    def delete_last(self):
        self.delete(self.tail.prev)

    def delete_first_value(self, v):
        node = self.find(v, self.head)
        if node is not None:
            self.delete(node)

    def find(self, v, cur=None):
        if cur is None:
            cur = self.head

        while cur != self.tail:
            cur = cur.next
            if cur.value == v:
                return cur

        return None

    def __str__(self):
        cur = self.head.next
        vs = ''
        while cur != self.tail:
            vs += cur.value
            cur = cur.next
            if cur != self.tail:
                vs += ' '

        return vs DoubleLinkedList
import sys


class DoubleLinkedList:
    class Node:
        def __init__(self, value=None, prev=None, _next=None):
            self.value = value
            self.prev = prev
            self.next = _next

    def __init__(self):
        self.head = self.Node()
        self.tail = self.Node()
        self.head.next = self.tail
        self.tail.prev = self.head

    def insert(self, v):
        head = self.head
        node = self.Node(v, head, head.next)
        head.next.prev = node
        head.next = node

    def delete(self, node):
        if node in (self.head, self.tail):
            return
        else:
            node.prev.next, node.next.prev = node.next, node.prev

    def delete_first(self):
        self.delete(self.head.next)

    def delete_last(self):
        self.delete(self.tail.prev)

    def delete_first_value(self, v):
        node = self.find(v, self.head)
        if node is not None:
            self.delete(node)

    def find(self, v, cur=None):
        if cur is None:
            cur = self.head

        while cur != self.tail:
            cur = cur.next
            if cur.value == v:
                return cur

        return None

    def __str__(self):
        cur = self.head.next
        vs = ''
        while cur != self.tail:
            vs += cur.value
            cur = cur.next
            if cur != self.tail:
                vs += ' '

        return vs


def run():
    steps = int(input())  # flake8: noqa
    dl = DoubleLinkedList()

    for command in sys.stdin:
        if command.startswith('insert'):
            dl.insert(command[7:-1])
        elif command.startswith('deleteFirst'):
            dl.delete_first()
        elif command.startswith('deleteLast'):
            dl.delete_last()
        elif command.startswith('delete'):
            dl.delete_first_value(command[7:-1])
        else:
            raise ValueError()

    print(dl)


if __name__ == '__main__':
    run()

