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

class DoublyLinkedList(object):
    def __init__(self):
        self.first = Node()
        self.first.prev = self.first
        self.first.next = self.first

    def insert(self, key):
        x = Node(key)
        x.next = self.first.next
        self.first.next.prev = x
        self.first.next = x
        x.prev = self.first

    def search(self, key):
        cur = self.first.next
        while cur != self.first and cur.key != key:
            cur = cur.next

        return cur

    def delete(self, key):
        self.delete_node(self.search(key))

    def delete_node(self, node):
        if node == self.first:
            return
        else:
            node.prev.next = node.next
            node.next.prev = node.prev

    def delete_first(self):
        self.delete_node(self.first.next)

    def delete_last(self):
        self.delete_node(self.first.prev)


if __name__ == "__main__":
    import sys
    input = sys.stdin.readline # faster input

    linklist = DoublyLinkedList()

    n = int(input())

    for _ in range(n):
        inputs = input().rstrip()
        if inputs[0] == 'i':
            linklist.insert(inputs[7:])
        elif inputs[6] == 'F':
            linklist.delete_first()
        elif inputs[6] == 'L':
            linklist.delete_last()
        else:
            linklist.delete(inputs[7:])

    result = []
    cur = linklist.first.next
    while cur != linklist.first:
        result.append(cur.key)
        cur = cur.next

    print(' '.join(result))
 class Node(object):
    def __init__(self, key=None):
        self.key = key
        self.prev = None
        self.next = None Node def __init__(self, key=None):
        self.key = key
        self.prev = None
        self.next = None __init__ self.key = key self.key self key key self.prev = None self.prev self prev None self.next = None self.next self next None self self key=None key None object class DoublyLinkedList(object):
    def __init__(self):
        self.first = Node()
        self.first.prev = self.first
        self.first.next = self.first

    def insert(self, key):
        x = Node(key)
        x.next = self.first.next
        self.first.next.prev = x
        self.first.next = x
        x.prev = self.first

    def search(self, key):
        cur = self.first.next
        while cur != self.first and cur.key != key:
            cur = cur.next

        return cur

    def delete(self, key):
        self.delete_node(self.search(key))

    def delete_node(self, node):
        if node == self.first:
            return
        else:
            node.prev.next = node.next
            node.next.prev = node.prev

    def delete_first(self):
        self.delete_node(self.first.next)

    def delete_last(self):
        self.delete_node(self.first.prev) DoublyLinkedList def __init__(self):
        self.first = Node()
        self.first.prev = self.first
        self.first.next = self.first

     __init__ self.first = Node() self.first self first Node() Node self.first.prev = self.first self.first.prev self.first self first prev self.first self first self.first.next = self.first self.first.next self.first self first next self.first self first self self def insert(self, key):
        x = Node(key)
        x.next = self.first.next
        self.first.next.prev = x
        self.first.next = x
        x.prev = self.first

     insert x = Node(key) x Node(key) Node key x.next = self.first.next x.next x next self.first.next self.first self first next self.first.next.prev = x self.first.next.prev self.first.next self.first self first next prev x self.first.next = x self.first.next self.first self first next x x.prev = self.first x.prev x prev self.first self first self self key key def search(self, key):
        cur = self.first.next
        while cur != self.first and cur.key != key:
            cur = cur.next

        return cur

     search cur = self.first.next cur self.first.next self.first self first next while cur != self.first and cur.key != key:
            cur = cur.next

         cur != self.first and cur.key != key cur != self.first cur self.first self first cur.key != key cur.key cur key key cur = cur.next cur cur.next cur next return cur cur self self key key def delete(self, key):
        self.delete_node(self.search(key))

     delete self.delete_node(self.search(key)) self.delete_node self delete_node self.search(key) self.search self search key self self key key def delete_node(self, node):
        if node == self.first:
            return
        else:
            node.prev.next = node.next
            node.next.prev = node.prev

     delete_node if node == self.first:
            return
        else:
            node.prev.next = node.next
            node.next.prev = node.prev

     node == self.first node self.first self first return 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 delete_first(self):
        self.delete_node(self.first.next)

     delete_first self.delete_node(self.first.next) self.delete_node self delete_node self.first.next self.first self first next self self def delete_last(self):
        self.delete_node(self.first.prev) delete_last self.delete_node(self.first.prev) self.delete_node self delete_node self.first.prev self.first self first prev self self object if __name__ == "__main__":
    import sys
    input = sys.stdin.readline # faster input

    linklist = DoublyLinkedList()

    n = int(input())

    for _ in range(n):
        inputs = input().rstrip()
        if inputs[0] == 'i':
            linklist.insert(inputs[7:])
        elif inputs[6] == 'F':
            linklist.delete_first()
        elif inputs[6] == 'L':
            linklist.delete_last()
        else:
            linklist.delete(inputs[7:])

    result = []
    cur = linklist.first.next
    while cur != linklist.first:
        result.append(cur.key)
        cur = cur.next

    print(' '.join(result)) __name__ == "__main__" __name__ "__main__" import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline linklist = DoublyLinkedList() linklist DoublyLinkedList() DoublyLinkedList n = int(input()) n int(input()) int input() input for _ in range(n):
        inputs = input().rstrip()
        if inputs[0] == 'i':
            linklist.insert(inputs[7:])
        elif inputs[6] == 'F':
            linklist.delete_first()
        elif inputs[6] == 'L':
            linklist.delete_last()
        else:
            linklist.delete(inputs[7:])

     _ range(n) range n inputs = input().rstrip() inputs input().rstrip() ().rstrip () input rstrip if inputs[0] == 'i':
            linklist.insert(inputs[7:])
        elif inputs[6] == 'F':
            linklist.delete_first()
        elif inputs[6] == 'L':
            linklist.delete_last()
        else:
            linklist.delete(inputs[7:])

     inputs[0] == 'i' inputs[0] inputs 0 'i' linklist.insert(inputs[7:]) linklist.insert linklist insert inputs[7:] inputs 7: 7 elif inputs[6] == 'F':
            linklist.delete_first()
         inputs[6] == 'F' inputs[6] inputs 6 'F' linklist.delete_first() linklist.delete_first linklist delete_first elif inputs[6] == 'L':
            linklist.delete_last()
         inputs[6] == 'L' inputs[6] inputs 6 'L' linklist.delete_last() linklist.delete_last linklist delete_last linklist.delete(inputs[7:]) linklist.delete linklist delete inputs[7:] inputs 7: 7 result = [] result [] cur = linklist.first.next cur linklist.first.next linklist.first linklist first next while cur != linklist.first:
        result.append(cur.key)
        cur = cur.next

     cur != linklist.first cur linklist.first linklist first result.append(cur.key) result.append result append cur.key cur key cur = cur.next cur cur.next cur next print(' '.join(result)) print ' '.join(result) ' '.join ' ' join result inputs = input().rstrip() input().rstrip() inputs class DoublyLinkedList(object):
    def __init__(self):
        self.first = Node()
        self.first.prev = self.first
        self.first.next = self.first

    def insert(self, key):
        x = Node(key)
        x.next = self.first.next
        self.first.next.prev = x
        self.first.next = x
        x.prev = self.first

    def search(self, key):
        cur = self.first.next
        while cur != self.first and cur.key != key:
            cur = cur.next

        return cur

    def delete(self, key):
        self.delete_node(self.search(key))

    def delete_node(self, node):
        if node == self.first:
            return
        else:
            node.prev.next = node.next
            node.next.prev = node.prev

    def delete_first(self):
        self.delete_node(self.first.next)

    def delete_last(self):
        self.delete_node(self.first.prev) class DoublyLinkedList(object):
    def __init__(self):
        self.first = Node()
        self.first.prev = self.first
        self.first.next = self.first

    def insert(self, key):
        x = Node(key)
        x.next = self.first.next
        self.first.next.prev = x
        self.first.next = x
        x.prev = self.first

    def search(self, key):
        cur = self.first.next
        while cur != self.first and cur.key != key:
            cur = cur.next

        return cur

    def delete(self, key):
        self.delete_node(self.search(key))

    def delete_node(self, node):
        if node == self.first:
            return
        else:
            node.prev.next = node.next
            node.next.prev = node.prev

    def delete_first(self):
        self.delete_node(self.first.next)

    def delete_last(self):
        self.delete_node(self.first.prev) DoublyLinkedList cur = cur.next cur.next cur linklist = DoublyLinkedList() DoublyLinkedList() linklist cur = linklist.first.next linklist.first.next cur result = [] [] result class Node(object):
    def __init__(self, key=None):
        self.key = key
        self.prev = None
        self.next = None class Node(object):
    def __init__(self, key=None):
        self.key = key
        self.prev = None
        self.next = None Node input = sys.stdin.readline sys.stdin.readline input n = int(input()) int(input()) n
class Node(object):
    def __init__(self, key=None):
        self.key = key
        self.prev = None
        self.next = None

class DoublyLinkedList(object):
    def __init__(self):
        self.first = Node()
        self.first.prev = self.first
        self.first.next = self.first

    def insert(self, key):
        x = Node(key)
        x.next = self.first.next
        self.first.next.prev = x
        self.first.next = x
        x.prev = self.first

    def search(self, key):
        cur = self.first.next
        while cur != self.first and cur.key != key:
            cur = cur.next

        return cur

    def delete(self, key):
        self.delete_node(self.search(key))

    def delete_node(self, node):
        if node == self.first:
            return
        else:
            node.prev.next = node.next
            node.next.prev = node.prev

    def delete_first(self):
        self.delete_node(self.first.next)

    def delete_last(self):
        self.delete_node(self.first.prev)


if __name__ == "__main__":
    import sys
    input = sys.stdin.readline # faster input

    linklist = DoublyLinkedList()

    n = int(input())

    for _ in range(n):
        inputs = input().rstrip()
        if inputs[0] == 'i':
            linklist.insert(inputs[7:])
        elif inputs[6] == 'F':
            linklist.delete_first()
        elif inputs[6] == 'L':
            linklist.delete_last()
        else:
            linklist.delete(inputs[7:])

    result = []
    cur = linklist.first.next
    while cur != linklist.first:
        result.append(cur.key)
        cur = cur.next

    print(' '.join(result))

