from sys import stdin

class Node:
    def __init__(self, value: int):
        self.value = value
        self.previous_node = None
        self.next_node = None


class LinkedList():
    def __init__(self):
        self.first = None
        self.last = None
    
    def delete_node(self, node: Node):
        if node.next_node != None:
            node.next_node.previous_node = node.previous_node
        if node.previous_node != None:
            node.previous_node.next_node = node.next_node
        if node == self.first:
            self.first = node.next_node
        if node == self.last:
            self.last = node.previous_node

    def value_generator(self):
        node = self.first
        while node != None:
            yield node.value
            node = node.next_node

    def insert(self, x: int):
        node = Node(x)
        node.next_node = self.first
        if self.first != None:
            self.first.previous_node = node
        self.first = node
        if self.last == None:
            self.last = node

    def delete(self, x: int):
        target_node = self.first
        while target_node != None and target_node.value != x:
            target_node = target_node.next_node
        if target_node != None:
            self.delete_node(target_node)


def main():
    linked_list = LinkedList()
    insert,delete,delete_node = linked_list.insert,linked_list.delete,linked_list.delete_node
    _ = int(stdin.readline())
    for line in (line.split() for line in stdin.readlines()):
        command = line[0]
        if command == "insert":
            insert(int(line[1]))
        elif command == "delete":
            delete(int(line[1]))
        elif command == "deleteFirst":
            delete_node(linked_list.first)
        elif command == "deleteLast":
            delete_node(linked_list.last)
    print(*linked_list.value_generator())


main() from sys import stdin class Node:
    def __init__(self, value: int):
        self.value = value
        self.previous_node = None
        self.next_node = None Node def __init__(self, value: int):
        self.value = value
        self.previous_node = None
        self.next_node = None __init__ self.value = value self.value self value value self.previous_node = None self.previous_node self previous_node None self.next_node = None self.next_node self next_node None self self value: int value class LinkedList():
    def __init__(self):
        self.first = None
        self.last = None
    
    def delete_node(self, node: Node):
        if node.next_node != None:
            node.next_node.previous_node = node.previous_node
        if node.previous_node != None:
            node.previous_node.next_node = node.next_node
        if node == self.first:
            self.first = node.next_node
        if node == self.last:
            self.last = node.previous_node

    def value_generator(self):
        node = self.first
        while node != None:
            yield node.value
            node = node.next_node

    def insert(self, x: int):
        node = Node(x)
        node.next_node = self.first
        if self.first != None:
            self.first.previous_node = node
        self.first = node
        if self.last == None:
            self.last = node

    def delete(self, x: int):
        target_node = self.first
        while target_node != None and target_node.value != x:
            target_node = target_node.next_node
        if target_node != None:
            self.delete_node(target_node) LinkedList def __init__(self):
        self.first = None
        self.last = None
    
     __init__ self.first = None self.first self first None self.last = None self.last self last None self self def delete_node(self, node: Node):
        if node.next_node != None:
            node.next_node.previous_node = node.previous_node
        if node.previous_node != None:
            node.previous_node.next_node = node.next_node
        if node == self.first:
            self.first = node.next_node
        if node == self.last:
            self.last = node.previous_node

     delete_node if node.next_node != None:
            node.next_node.previous_node = node.previous_node
         node.next_node != None node.next_node node next_node None node.next_node.previous_node = node.previous_node node.next_node.previous_node node.next_node node next_node previous_node node.previous_node node previous_node if node.previous_node != None:
            node.previous_node.next_node = node.next_node
         node.previous_node != None node.previous_node node previous_node None node.previous_node.next_node = node.next_node node.previous_node.next_node node.previous_node node previous_node next_node node.next_node node next_node if node == self.first:
            self.first = node.next_node
         node == self.first node self.first self first self.first = node.next_node self.first self first node.next_node node next_node if node == self.last:
            self.last = node.previous_node

     node == self.last node self.last self last self.last = node.previous_node self.last self last node.previous_node node previous_node self self node: Node node def value_generator(self):
        node = self.first
        while node != None:
            yield node.value
            node = node.next_node

     value_generator node = self.first node self.first self first while node != None:
            yield node.value
            node = node.next_node

     node != None node None yield node.value node.value node value node = node.next_node node node.next_node node next_node self self def insert(self, x: int):
        node = Node(x)
        node.next_node = self.first
        if self.first != None:
            self.first.previous_node = node
        self.first = node
        if self.last == None:
            self.last = node

     insert node = Node(x) node Node(x) Node x node.next_node = self.first node.next_node node next_node self.first self first if self.first != None:
            self.first.previous_node = node
         self.first != None self.first self first None self.first.previous_node = node self.first.previous_node self.first self first previous_node node self.first = node self.first self first node if self.last == None:
            self.last = node

     self.last == None self.last self last None self.last = node self.last self last node self self x: int x def delete(self, x: int):
        target_node = self.first
        while target_node != None and target_node.value != x:
            target_node = target_node.next_node
        if target_node != None:
            self.delete_node(target_node) delete target_node = self.first target_node self.first self first while target_node != None and target_node.value != x:
            target_node = target_node.next_node
         target_node != None and target_node.value != x target_node != None target_node None target_node.value != x target_node.value target_node value x target_node = target_node.next_node target_node target_node.next_node target_node next_node if target_node != None:
            self.delete_node(target_node) target_node != None target_node None self.delete_node(target_node) self.delete_node self delete_node target_node self self x: int x def main():
    linked_list = LinkedList()
    insert,delete,delete_node = linked_list.insert,linked_list.delete,linked_list.delete_node
    _ = int(stdin.readline())
    for line in (line.split() for line in stdin.readlines()):
        command = line[0]
        if command == "insert":
            insert(int(line[1]))
        elif command == "delete":
            delete(int(line[1]))
        elif command == "deleteFirst":
            delete_node(linked_list.first)
        elif command == "deleteLast":
            delete_node(linked_list.last)
    print(*linked_list.value_generator()) main linked_list = LinkedList() linked_list LinkedList() LinkedList insert,delete,delete_node = linked_list.insert,linked_list.delete,linked_list.delete_node insert linked_list.insert linked_list insert delete linked_list.delete linked_list delete delete_node linked_list.delete_node linked_list delete_node _ = int(stdin.readline()) _ int(stdin.readline()) int stdin.readline() stdin.readline stdin readline for line in (line.split() for line in stdin.readlines()):
        command = line[0]
        if command == "insert":
            insert(int(line[1]))
        elif command == "delete":
            delete(int(line[1]))
        elif command == "deleteFirst":
            delete_node(linked_list.first)
        elif command == "deleteLast":
            delete_node(linked_list.last)
     line (line.split() for line in stdin.readlines()) command = line[0] command line[0] line 0 if command == "insert":
            insert(int(line[1]))
        elif command == "delete":
            delete(int(line[1]))
        elif command == "deleteFirst":
            delete_node(linked_list.first)
        elif command == "deleteLast":
            delete_node(linked_list.last)
     command == "insert" command "insert" insert(int(line[1])) insert int(line[1]) int line[1] line 1 elif command == "delete":
            delete(int(line[1]))
         command == "delete" command "delete" delete(int(line[1])) delete int(line[1]) int line[1] line 1 elif command == "deleteFirst":
            delete_node(linked_list.first)
         command == "deleteFirst" command "deleteFirst" delete_node(linked_list.first) delete_node linked_list.first linked_list first elif command == "deleteLast":
            delete_node(linked_list.last)
     command == "deleteLast" command "deleteLast" delete_node(linked_list.last) delete_node linked_list.last linked_list last print(*linked_list.value_generator()) print *linked_list.value_generator() linked_list.value_generator() linked_list.value_generator linked_list value_generator main() main def main():
    linked_list = LinkedList()
    insert,delete,delete_node = linked_list.insert,linked_list.delete,linked_list.delete_node
    _ = int(stdin.readline())
    for line in (line.split() for line in stdin.readlines()):
        command = line[0]
        if command == "insert":
            insert(int(line[1]))
        elif command == "delete":
            delete(int(line[1]))
        elif command == "deleteFirst":
            delete_node(linked_list.first)
        elif command == "deleteLast":
            delete_node(linked_list.last)
    print(*linked_list.value_generator()) def main():
    linked_list = LinkedList()
    insert,delete,delete_node = linked_list.insert,linked_list.delete,linked_list.delete_node
    _ = int(stdin.readline())
    for line in (line.split() for line in stdin.readlines()):
        command = line[0]
        if command == "insert":
            insert(int(line[1]))
        elif command == "delete":
            delete(int(line[1]))
        elif command == "deleteFirst":
            delete_node(linked_list.first)
        elif command == "deleteLast":
            delete_node(linked_list.last)
    print(*linked_list.value_generator()) main class LinkedList():
    def __init__(self):
        self.first = None
        self.last = None
    
    def delete_node(self, node: Node):
        if node.next_node != None:
            node.next_node.previous_node = node.previous_node
        if node.previous_node != None:
            node.previous_node.next_node = node.next_node
        if node == self.first:
            self.first = node.next_node
        if node == self.last:
            self.last = node.previous_node

    def value_generator(self):
        node = self.first
        while node != None:
            yield node.value
            node = node.next_node

    def insert(self, x: int):
        node = Node(x)
        node.next_node = self.first
        if self.first != None:
            self.first.previous_node = node
        self.first = node
        if self.last == None:
            self.last = node

    def delete(self, x: int):
        target_node = self.first
        while target_node != None and target_node.value != x:
            target_node = target_node.next_node
        if target_node != None:
            self.delete_node(target_node) class LinkedList():
    def __init__(self):
        self.first = None
        self.last = None
    
    def delete_node(self, node: Node):
        if node.next_node != None:
            node.next_node.previous_node = node.previous_node
        if node.previous_node != None:
            node.previous_node.next_node = node.next_node
        if node == self.first:
            self.first = node.next_node
        if node == self.last:
            self.last = node.previous_node

    def value_generator(self):
        node = self.first
        while node != None:
            yield node.value
            node = node.next_node

    def insert(self, x: int):
        node = Node(x)
        node.next_node = self.first
        if self.first != None:
            self.first.previous_node = node
        self.first = node
        if self.last == None:
            self.last = node

    def delete(self, x: int):
        target_node = self.first
        while target_node != None and target_node.value != x:
            target_node = target_node.next_node
        if target_node != None:
            self.delete_node(target_node) LinkedList class Node:
    def __init__(self, value: int):
        self.value = value
        self.previous_node = None
        self.next_node = None class Node:
    def __init__(self, value: int):
        self.value = value
        self.previous_node = None
        self.next_node = None Node
from sys import stdin

class Node:
    def __init__(self, value: int):
        self.value = value
        self.previous_node = None
        self.next_node = None


class LinkedList():
    def __init__(self):
        self.first = None
        self.last = None
    
    def delete_node(self, node: Node):
        if node.next_node != None:
            node.next_node.previous_node = node.previous_node
        if node.previous_node != None:
            node.previous_node.next_node = node.next_node
        if node == self.first:
            self.first = node.next_node
        if node == self.last:
            self.last = node.previous_node

    def value_generator(self):
        node = self.first
        while node != None:
            yield node.value
            node = node.next_node

    def insert(self, x: int):
        node = Node(x)
        node.next_node = self.first
        if self.first != None:
            self.first.previous_node = node
        self.first = node
        if self.last == None:
            self.last = node

    def delete(self, x: int):
        target_node = self.first
        while target_node != None and target_node.value != x:
            target_node = target_node.next_node
        if target_node != None:
            self.delete_node(target_node)


def main():
    linked_list = LinkedList()
    insert,delete,delete_node = linked_list.insert,linked_list.delete,linked_list.delete_node
    _ = int(stdin.readline())
    for line in (line.split() for line in stdin.readlines()):
        command = line[0]
        if command == "insert":
            insert(int(line[1]))
        elif command == "delete":
            delete(int(line[1]))
        elif command == "deleteFirst":
            delete_node(linked_list.first)
        elif command == "deleteLast":
            delete_node(linked_list.last)
    print(*linked_list.value_generator())


main()
