class D_Linked_List:
    class Node:
        def __init__(self, key, next = None, prev = None):
            self.next = next
            self.prev = prev
            self.key = key

    def __init__(self):
        self.nil = D_Linked_List.Node(None)
        self.nil.next = self.nil
        self.nil.prev = self.nil

    def insert(self, key):
        node_x = D_Linked_List.Node(key, self.nil.next, self.nil)
        self.nil.next.prev = node_x
        self.nil.next = node_x

    def _listSearch(self, key):
        cur_node = self.nil.next
        while (cur_node != self.nil) and (cur_node.key != key):
            cur_node = cur_node.next
        return cur_node

    def _deleteNode(self, node):
        if node == self.nil:
            return None
        node.prev.next = node.next
        node.next.prev = node.prev

    def deleteFirst(self):
        self._deleteNode(self.nil.next)

    def deleteLast(self):
        self._deleteNode(self.nil.prev)

    def deleteKey(self, key):
        node = self._listSearch(key)
        self._deleteNode(node)

    def show_keys(self):
        cur_node = self.nil.next
        keys = []
        while cur_node != self.nil:
            keys.append(cur_node.key)
            cur_node = cur_node.next
        print(*keys)


import sys

d_ll = D_Linked_List()

for i in sys.stdin:
    if 'insert' in i:
        x = int(i.split()[1])
        d_ll.insert(x)
    elif 'deleteFirst' in i:
        d_ll.deleteFirst()
    elif 'deleteLast' in i:
        d_ll.deleteLast()
    elif 'delete' in i:
        x = int(i.split()[1])
        d_ll.deleteKey(x)
    else:
        pass

d_ll.show_keys() class D_Linked_List:
    class Node:
        def __init__(self, key, next = None, prev = None):
            self.next = next
            self.prev = prev
            self.key = key

    def __init__(self):
        self.nil = D_Linked_List.Node(None)
        self.nil.next = self.nil
        self.nil.prev = self.nil

    def insert(self, key):
        node_x = D_Linked_List.Node(key, self.nil.next, self.nil)
        self.nil.next.prev = node_x
        self.nil.next = node_x

    def _listSearch(self, key):
        cur_node = self.nil.next
        while (cur_node != self.nil) and (cur_node.key != key):
            cur_node = cur_node.next
        return cur_node

    def _deleteNode(self, node):
        if node == self.nil:
            return None
        node.prev.next = node.next
        node.next.prev = node.prev

    def deleteFirst(self):
        self._deleteNode(self.nil.next)

    def deleteLast(self):
        self._deleteNode(self.nil.prev)

    def deleteKey(self, key):
        node = self._listSearch(key)
        self._deleteNode(node)

    def show_keys(self):
        cur_node = self.nil.next
        keys = []
        while cur_node != self.nil:
            keys.append(cur_node.key)
            cur_node = cur_node.next
        print(*keys) D_Linked_List class Node:
        def __init__(self, key, next = None, prev = None):
            self.next = next
            self.prev = prev
            self.key = key

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

     __init__ self.next = next self.next self next next self.prev = prev self.prev self prev prev self.key = key self.key self key key self self key key next = None next None prev = None prev None def __init__(self):
        self.nil = D_Linked_List.Node(None)
        self.nil.next = self.nil
        self.nil.prev = self.nil

     __init__ self.nil = D_Linked_List.Node(None) self.nil self nil D_Linked_List.Node(None) D_Linked_List.Node D_Linked_List Node None self.nil.next = self.nil self.nil.next self.nil self nil next self.nil self nil self.nil.prev = self.nil self.nil.prev self.nil self nil prev self.nil self nil self self def insert(self, key):
        node_x = D_Linked_List.Node(key, self.nil.next, self.nil)
        self.nil.next.prev = node_x
        self.nil.next = node_x

     insert node_x = D_Linked_List.Node(key, self.nil.next, self.nil) node_x D_Linked_List.Node(key, self.nil.next, self.nil) D_Linked_List.Node D_Linked_List Node key self.nil.next self.nil self nil next self.nil self nil self.nil.next.prev = node_x self.nil.next.prev self.nil.next self.nil self nil next prev node_x self.nil.next = node_x self.nil.next self.nil self nil next node_x self self key key def _listSearch(self, key):
        cur_node = self.nil.next
        while (cur_node != self.nil) and (cur_node.key != key):
            cur_node = cur_node.next
        return cur_node

     _listSearch cur_node = self.nil.next cur_node self.nil.next self.nil self nil next while (cur_node != self.nil) and (cur_node.key != key):
            cur_node = cur_node.next
         (cur_node != self.nil) and (cur_node.key != key) cur_node != self.nil cur_node self.nil self nil cur_node.key != key cur_node.key cur_node key key cur_node = cur_node.next cur_node cur_node.next cur_node next return cur_node cur_node self self key key def _deleteNode(self, node):
        if node == self.nil:
            return None
        node.prev.next = node.next
        node.next.prev = node.prev

     _deleteNode if node == self.nil:
            return None
         node == self.nil node self.nil self nil return None None node.prev.next = node.next node.prev.next node.prev node prev next node.next node next node.next.prev = node.prev node.next.prev node.next node next prev node.prev node prev self self node node def deleteFirst(self):
        self._deleteNode(self.nil.next)

     deleteFirst self._deleteNode(self.nil.next) self._deleteNode self _deleteNode self.nil.next self.nil self nil next self self def deleteLast(self):
        self._deleteNode(self.nil.prev)

     deleteLast self._deleteNode(self.nil.prev) self._deleteNode self _deleteNode self.nil.prev self.nil self nil prev self self def deleteKey(self, key):
        node = self._listSearch(key)
        self._deleteNode(node)

     deleteKey node = self._listSearch(key) node self._listSearch(key) self._listSearch self _listSearch key self._deleteNode(node) self._deleteNode self _deleteNode node self self key key def show_keys(self):
        cur_node = self.nil.next
        keys = []
        while cur_node != self.nil:
            keys.append(cur_node.key)
            cur_node = cur_node.next
        print(*keys) show_keys cur_node = self.nil.next cur_node self.nil.next self.nil self nil next keys = [] keys [] while cur_node != self.nil:
            keys.append(cur_node.key)
            cur_node = cur_node.next
         cur_node != self.nil cur_node self.nil self nil keys.append(cur_node.key) keys.append keys append cur_node.key cur_node key cur_node = cur_node.next cur_node cur_node.next cur_node next print(*keys) print *keys keys self self import sys sys d_ll = D_Linked_List() d_ll D_Linked_List() D_Linked_List for i in sys.stdin:
    if 'insert' in i:
        x = int(i.split()[1])
        d_ll.insert(x)
    elif 'deleteFirst' in i:
        d_ll.deleteFirst()
    elif 'deleteLast' in i:
        d_ll.deleteLast()
    elif 'delete' in i:
        x = int(i.split()[1])
        d_ll.deleteKey(x)
    else:
        pass i sys.stdin sys stdin if 'insert' in i:
        x = int(i.split()[1])
        d_ll.insert(x)
    elif 'deleteFirst' in i:
        d_ll.deleteFirst()
    elif 'deleteLast' in i:
        d_ll.deleteLast()
    elif 'delete' in i:
        x = int(i.split()[1])
        d_ll.deleteKey(x)
    else:
        pass 'insert' in i 'insert' i x = int(i.split()[1]) x int(i.split()[1]) int i.split()[1] i.split() i.split i split 1 d_ll.insert(x) d_ll.insert d_ll insert x elif 'deleteFirst' in i:
        d_ll.deleteFirst()
     'deleteFirst' in i 'deleteFirst' i d_ll.deleteFirst() d_ll.deleteFirst d_ll deleteFirst elif 'deleteLast' in i:
        d_ll.deleteLast()
     'deleteLast' in i 'deleteLast' i d_ll.deleteLast() d_ll.deleteLast d_ll deleteLast elif 'delete' in i:
        x = int(i.split()[1])
        d_ll.deleteKey(x)
     'delete' in i 'delete' i x = int(i.split()[1]) x int(i.split()[1]) int i.split()[1] i.split() i.split i split 1 d_ll.deleteKey(x) d_ll.deleteKey d_ll deleteKey x d_ll.show_keys() d_ll.show_keys d_ll show_keys x = int(i.split()[1]) int(i.split()[1]) x class D_Linked_List:
    class Node:
        def __init__(self, key, next = None, prev = None):
            self.next = next
            self.prev = prev
            self.key = key

    def __init__(self):
        self.nil = D_Linked_List.Node(None)
        self.nil.next = self.nil
        self.nil.prev = self.nil

    def insert(self, key):
        node_x = D_Linked_List.Node(key, self.nil.next, self.nil)
        self.nil.next.prev = node_x
        self.nil.next = node_x

    def _listSearch(self, key):
        cur_node = self.nil.next
        while (cur_node != self.nil) and (cur_node.key != key):
            cur_node = cur_node.next
        return cur_node

    def _deleteNode(self, node):
        if node == self.nil:
            return None
        node.prev.next = node.next
        node.next.prev = node.prev

    def deleteFirst(self):
        self._deleteNode(self.nil.next)

    def deleteLast(self):
        self._deleteNode(self.nil.prev)

    def deleteKey(self, key):
        node = self._listSearch(key)
        self._deleteNode(node)

    def show_keys(self):
        cur_node = self.nil.next
        keys = []
        while cur_node != self.nil:
            keys.append(cur_node.key)
            cur_node = cur_node.next
        print(*keys) class D_Linked_List:
    class Node:
        def __init__(self, key, next = None, prev = None):
            self.next = next
            self.prev = prev
            self.key = key

    def __init__(self):
        self.nil = D_Linked_List.Node(None)
        self.nil.next = self.nil
        self.nil.prev = self.nil

    def insert(self, key):
        node_x = D_Linked_List.Node(key, self.nil.next, self.nil)
        self.nil.next.prev = node_x
        self.nil.next = node_x

    def _listSearch(self, key):
        cur_node = self.nil.next
        while (cur_node != self.nil) and (cur_node.key != key):
            cur_node = cur_node.next
        return cur_node

    def _deleteNode(self, node):
        if node == self.nil:
            return None
        node.prev.next = node.next
        node.next.prev = node.prev

    def deleteFirst(self):
        self._deleteNode(self.nil.next)

    def deleteLast(self):
        self._deleteNode(self.nil.prev)

    def deleteKey(self, key):
        node = self._listSearch(key)
        self._deleteNode(node)

    def show_keys(self):
        cur_node = self.nil.next
        keys = []
        while cur_node != self.nil:
            keys.append(cur_node.key)
            cur_node = cur_node.next
        print(*keys) D_Linked_List d_ll = D_Linked_List() D_Linked_List() d_ll x = int(i.split()[1]) int(i.split()[1]) x
class D_Linked_List:
    class Node:
        def __init__(self, key, next = None, prev = None):
            self.next = next
            self.prev = prev
            self.key = key

    def __init__(self):
        self.nil = D_Linked_List.Node(None)
        self.nil.next = self.nil
        self.nil.prev = self.nil

    def insert(self, key):
        node_x = D_Linked_List.Node(key, self.nil.next, self.nil)
        self.nil.next.prev = node_x
        self.nil.next = node_x

    def _listSearch(self, key):
        cur_node = self.nil.next
        while (cur_node != self.nil) and (cur_node.key != key):
            cur_node = cur_node.next
        return cur_node

    def _deleteNode(self, node):
        if node == self.nil:
            return None
        node.prev.next = node.next
        node.next.prev = node.prev

    def deleteFirst(self):
        self._deleteNode(self.nil.next)

    def deleteLast(self):
        self._deleteNode(self.nil.prev)

    def deleteKey(self, key):
        node = self._listSearch(key)
        self._deleteNode(node)

    def show_keys(self):
        cur_node = self.nil.next
        keys = []
        while cur_node != self.nil:
            keys.append(cur_node.key)
            cur_node = cur_node.next
        print(*keys)


import sys

d_ll = D_Linked_List()

for i in sys.stdin:
    if 'insert' in i:
        x = int(i.split()[1])
        d_ll.insert(x)
    elif 'deleteFirst' in i:
        d_ll.deleteFirst()
    elif 'deleteLast' in i:
        d_ll.deleteLast()
    elif 'delete' in i:
        x = int(i.split()[1])
        d_ll.deleteKey(x)
    else:
        pass

d_ll.show_keys()