import sys


class Node:
    def __init__(self, x):
        self.x = x

    def set_prev(self, prev):
        self.prev = prev

    def set_next(self, next):
        self.next = next


class DoublelyLinkedList:
    def __init__(self):
        self.nil = Node(None)
        self.nil.set_next(self.nil)
        self.nil.set_prev(self.nil)

    def insert(self, x):
        new_elem = Node(x)
        new_elem.set_next(self.nil.next)
        new_elem.set_prev(self.nil)
        self.nil.next.set_prev(new_elem)
        self.nil.set_next(new_elem)

    def list_search(self, x):
        cur = self.nil.next
        while cur != self.nil and cur.x != x:
            cur = cur.next
        return cur

    def _delete(self, node):
        node.prev.set_next(node.next)
        node.next.set_prev(node.prev)

    def delete_first(self):
        self._delete(self.nil.next)

    def delete_last(self):
        self._delete(self.nil.prev)

    def delete(self, x):
        del_node = self.list_search(x)
        if del_node.x is not None:
            self._delete(del_node)


def main():
    d_linked_list = DoublelyLinkedList()
    for i in sys.stdin:
        if 'insert' in i:
            x = i[7:-1]
            d_linked_list.insert(x)
        elif 'deleteFirst' in i:
            d_linked_list.delete_first()
        elif 'deleteLast' in i:
            d_linked_list.delete_last()
        elif 'delete' in i:
            x = i[7:-1]
            d_linked_list.delete(x)
        else:
            pass

    results = []
    cur = d_linked_list.nil.next
    while cur.x is not None:
        results.append(cur.x)
        cur = cur.next

    print(*results)


if __name__ == "__main__":
    main()
 import sys sys class Node:
    def __init__(self, x):
        self.x = x

    def set_prev(self, prev):
        self.prev = prev

    def set_next(self, next):
        self.next = next Node def __init__(self, x):
        self.x = x

     __init__ self.x = x self.x self x x self self x x def set_prev(self, prev):
        self.prev = prev

     set_prev self.prev = prev self.prev self prev prev self self prev prev def set_next(self, next):
        self.next = next set_next self.next = next self.next self next next self self next next class DoublelyLinkedList:
    def __init__(self):
        self.nil = Node(None)
        self.nil.set_next(self.nil)
        self.nil.set_prev(self.nil)

    def insert(self, x):
        new_elem = Node(x)
        new_elem.set_next(self.nil.next)
        new_elem.set_prev(self.nil)
        self.nil.next.set_prev(new_elem)
        self.nil.set_next(new_elem)

    def list_search(self, x):
        cur = self.nil.next
        while cur != self.nil and cur.x != x:
            cur = cur.next
        return cur

    def _delete(self, node):
        node.prev.set_next(node.next)
        node.next.set_prev(node.prev)

    def delete_first(self):
        self._delete(self.nil.next)

    def delete_last(self):
        self._delete(self.nil.prev)

    def delete(self, x):
        del_node = self.list_search(x)
        if del_node.x is not None:
            self._delete(del_node) DoublelyLinkedList def __init__(self):
        self.nil = Node(None)
        self.nil.set_next(self.nil)
        self.nil.set_prev(self.nil)

     __init__ self.nil = Node(None) self.nil self nil Node(None) Node None self.nil.set_next(self.nil) self.nil.set_next self.nil self nil set_next self.nil self nil self.nil.set_prev(self.nil) self.nil.set_prev self.nil self nil set_prev self.nil self nil self self def insert(self, x):
        new_elem = Node(x)
        new_elem.set_next(self.nil.next)
        new_elem.set_prev(self.nil)
        self.nil.next.set_prev(new_elem)
        self.nil.set_next(new_elem)

     insert new_elem = Node(x) new_elem Node(x) Node x new_elem.set_next(self.nil.next) new_elem.set_next new_elem set_next self.nil.next self.nil self nil next new_elem.set_prev(self.nil) new_elem.set_prev new_elem set_prev self.nil self nil self.nil.next.set_prev(new_elem) self.nil.next.set_prev self.nil.next self.nil self nil next set_prev new_elem self.nil.set_next(new_elem) self.nil.set_next self.nil self nil set_next new_elem self self x x def list_search(self, x):
        cur = self.nil.next
        while cur != self.nil and cur.x != x:
            cur = cur.next
        return cur

     list_search cur = self.nil.next cur self.nil.next self.nil self nil next while cur != self.nil and cur.x != x:
            cur = cur.next
         cur != self.nil and cur.x != x cur != self.nil cur self.nil self nil cur.x != x cur.x cur x x cur = cur.next cur cur.next cur next return cur cur self self x x def _delete(self, node):
        node.prev.set_next(node.next)
        node.next.set_prev(node.prev)

     _delete node.prev.set_next(node.next) node.prev.set_next node.prev node prev set_next node.next node next node.next.set_prev(node.prev) node.next.set_prev node.next node next set_prev node.prev node prev self self node node def delete_first(self):
        self._delete(self.nil.next)

     delete_first self._delete(self.nil.next) self._delete self _delete self.nil.next self.nil self nil next self self def delete_last(self):
        self._delete(self.nil.prev)

     delete_last self._delete(self.nil.prev) self._delete self _delete self.nil.prev self.nil self nil prev self self def delete(self, x):
        del_node = self.list_search(x)
        if del_node.x is not None:
            self._delete(del_node) delete del_node = self.list_search(x) del_node self.list_search(x) self.list_search self list_search x if del_node.x is not None:
            self._delete(del_node) del_node.x is not None del_node.x del_node x None self._delete(del_node) self._delete self _delete del_node self self x x def main():
    d_linked_list = DoublelyLinkedList()
    for i in sys.stdin:
        if 'insert' in i:
            x = i[7:-1]
            d_linked_list.insert(x)
        elif 'deleteFirst' in i:
            d_linked_list.delete_first()
        elif 'deleteLast' in i:
            d_linked_list.delete_last()
        elif 'delete' in i:
            x = i[7:-1]
            d_linked_list.delete(x)
        else:
            pass

    results = []
    cur = d_linked_list.nil.next
    while cur.x is not None:
        results.append(cur.x)
        cur = cur.next

    print(*results) main d_linked_list = DoublelyLinkedList() d_linked_list DoublelyLinkedList() DoublelyLinkedList for i in sys.stdin:
        if 'insert' in i:
            x = i[7:-1]
            d_linked_list.insert(x)
        elif 'deleteFirst' in i:
            d_linked_list.delete_first()
        elif 'deleteLast' in i:
            d_linked_list.delete_last()
        elif 'delete' in i:
            x = i[7:-1]
            d_linked_list.delete(x)
        else:
            pass

     i sys.stdin sys stdin if 'insert' in i:
            x = i[7:-1]
            d_linked_list.insert(x)
        elif 'deleteFirst' in i:
            d_linked_list.delete_first()
        elif 'deleteLast' in i:
            d_linked_list.delete_last()
        elif 'delete' in i:
            x = i[7:-1]
            d_linked_list.delete(x)
        else:
            pass

     'insert' in i 'insert' i x = i[7:-1] x i[7:-1] i 7:-1 7 -1 d_linked_list.insert(x) d_linked_list.insert d_linked_list insert x elif 'deleteFirst' in i:
            d_linked_list.delete_first()
         'deleteFirst' in i 'deleteFirst' i d_linked_list.delete_first() d_linked_list.delete_first d_linked_list delete_first elif 'deleteLast' in i:
            d_linked_list.delete_last()
         'deleteLast' in i 'deleteLast' i d_linked_list.delete_last() d_linked_list.delete_last d_linked_list delete_last elif 'delete' in i:
            x = i[7:-1]
            d_linked_list.delete(x)
         'delete' in i 'delete' i x = i[7:-1] x i[7:-1] i 7:-1 7 -1 d_linked_list.delete(x) d_linked_list.delete d_linked_list delete x results = [] results [] cur = d_linked_list.nil.next cur d_linked_list.nil.next d_linked_list.nil d_linked_list nil next while cur.x is not None:
        results.append(cur.x)
        cur = cur.next

     cur.x is not None cur.x cur x None results.append(cur.x) results.append results append cur.x cur x cur = cur.next cur cur.next cur next print(*results) print *results results if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    d_linked_list = DoublelyLinkedList()
    for i in sys.stdin:
        if 'insert' in i:
            x = i[7:-1]
            d_linked_list.insert(x)
        elif 'deleteFirst' in i:
            d_linked_list.delete_first()
        elif 'deleteLast' in i:
            d_linked_list.delete_last()
        elif 'delete' in i:
            x = i[7:-1]
            d_linked_list.delete(x)
        else:
            pass

    results = []
    cur = d_linked_list.nil.next
    while cur.x is not None:
        results.append(cur.x)
        cur = cur.next

    print(*results) def main():
    d_linked_list = DoublelyLinkedList()
    for i in sys.stdin:
        if 'insert' in i:
            x = i[7:-1]
            d_linked_list.insert(x)
        elif 'deleteFirst' in i:
            d_linked_list.delete_first()
        elif 'deleteLast' in i:
            d_linked_list.delete_last()
        elif 'delete' in i:
            x = i[7:-1]
            d_linked_list.delete(x)
        else:
            pass

    results = []
    cur = d_linked_list.nil.next
    while cur.x is not None:
        results.append(cur.x)
        cur = cur.next

    print(*results) main class Node:
    def __init__(self, x):
        self.x = x

    def set_prev(self, prev):
        self.prev = prev

    def set_next(self, next):
        self.next = next class Node:
    def __init__(self, x):
        self.x = x

    def set_prev(self, prev):
        self.prev = prev

    def set_next(self, next):
        self.next = next Node class DoublelyLinkedList:
    def __init__(self):
        self.nil = Node(None)
        self.nil.set_next(self.nil)
        self.nil.set_prev(self.nil)

    def insert(self, x):
        new_elem = Node(x)
        new_elem.set_next(self.nil.next)
        new_elem.set_prev(self.nil)
        self.nil.next.set_prev(new_elem)
        self.nil.set_next(new_elem)

    def list_search(self, x):
        cur = self.nil.next
        while cur != self.nil and cur.x != x:
            cur = cur.next
        return cur

    def _delete(self, node):
        node.prev.set_next(node.next)
        node.next.set_prev(node.prev)

    def delete_first(self):
        self._delete(self.nil.next)

    def delete_last(self):
        self._delete(self.nil.prev)

    def delete(self, x):
        del_node = self.list_search(x)
        if del_node.x is not None:
            self._delete(del_node) class DoublelyLinkedList:
    def __init__(self):
        self.nil = Node(None)
        self.nil.set_next(self.nil)
        self.nil.set_prev(self.nil)

    def insert(self, x):
        new_elem = Node(x)
        new_elem.set_next(self.nil.next)
        new_elem.set_prev(self.nil)
        self.nil.next.set_prev(new_elem)
        self.nil.set_next(new_elem)

    def list_search(self, x):
        cur = self.nil.next
        while cur != self.nil and cur.x != x:
            cur = cur.next
        return cur

    def _delete(self, node):
        node.prev.set_next(node.next)
        node.next.set_prev(node.prev)

    def delete_first(self):
        self._delete(self.nil.next)

    def delete_last(self):
        self._delete(self.nil.prev)

    def delete(self, x):
        del_node = self.list_search(x)
        if del_node.x is not None:
            self._delete(del_node) DoublelyLinkedList
import sys


class Node:
    def __init__(self, x):
        self.x = x

    def set_prev(self, prev):
        self.prev = prev

    def set_next(self, next):
        self.next = next


class DoublelyLinkedList:
    def __init__(self):
        self.nil = Node(None)
        self.nil.set_next(self.nil)
        self.nil.set_prev(self.nil)

    def insert(self, x):
        new_elem = Node(x)
        new_elem.set_next(self.nil.next)
        new_elem.set_prev(self.nil)
        self.nil.next.set_prev(new_elem)
        self.nil.set_next(new_elem)

    def list_search(self, x):
        cur = self.nil.next
        while cur != self.nil and cur.x != x:
            cur = cur.next
        return cur

    def _delete(self, node):
        node.prev.set_next(node.next)
        node.next.set_prev(node.prev)

    def delete_first(self):
        self._delete(self.nil.next)

    def delete_last(self):
        self._delete(self.nil.prev)

    def delete(self, x):
        del_node = self.list_search(x)
        if del_node.x is not None:
            self._delete(del_node)


def main():
    d_linked_list = DoublelyLinkedList()
    for i in sys.stdin:
        if 'insert' in i:
            x = i[7:-1]
            d_linked_list.insert(x)
        elif 'deleteFirst' in i:
            d_linked_list.delete_first()
        elif 'deleteLast' in i:
            d_linked_list.delete_last()
        elif 'delete' in i:
            x = i[7:-1]
            d_linked_list.delete(x)
        else:
            pass

    results = []
    cur = d_linked_list.nil.next
    while cur.x is not None:
        results.append(cur.x)
        cur = cur.next

    print(*results)


if __name__ == "__main__":
    main()

