import sys
input = sys.stdin.readline

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

class DoublyLinkedList:
    def __init__(self):
        self.sentinel = Node(None)
        self.sentinel.prev = self.sentinel
        self.sentinel.next = self.sentinel

    def insert(self, val):
        node = Node(val)
        node.prev = self.sentinel
        node.next = self.sentinel.next
        self.sentinel.next.prev = node
        self.sentinel.next = node

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

    def deleteFirst(self):
        self.delete_node(self.sentinel.next)

    def deleteLast(self):
        self.delete_node(self.sentinel.prev)

    def search(self, val):
        cursor = self.sentinel.next
        while cursor != self.sentinel and cursor.val != val:
            cursor = cursor.next
        return cursor

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

n = int(input())
linked_list = DoublyLinkedList()
for index in range(n):
    command = input().rstrip()
    if command[0] == 'i':
        linked_list.insert(command[7:])
    elif command[6] == 'F':
        linked_list.deleteFirst()
    elif command[6] == 'L':
        linked_list.deleteLast()
    else:
        linked_list.delete(command[7:])

node = linked_list.sentinel.next
output = []
while node != linked_list.sentinel:
    output.append(node.val)
    node = node.next
print(" ".join(map(str, output))) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline class Node:
    def __init__(self, val):
        self.val  = val
        self.prev = None
        self.next = None Node def __init__(self, val):
        self.val  = val
        self.prev = None
        self.next = None __init__ self.val  = val self.val self val val self.prev = None self.prev self prev None self.next = None self.next self next None self self val val class DoublyLinkedList:
    def __init__(self):
        self.sentinel = Node(None)
        self.sentinel.prev = self.sentinel
        self.sentinel.next = self.sentinel

    def insert(self, val):
        node = Node(val)
        node.prev = self.sentinel
        node.next = self.sentinel.next
        self.sentinel.next.prev = node
        self.sentinel.next = node

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

    def deleteFirst(self):
        self.delete_node(self.sentinel.next)

    def deleteLast(self):
        self.delete_node(self.sentinel.prev)

    def search(self, val):
        cursor = self.sentinel.next
        while cursor != self.sentinel and cursor.val != val:
            cursor = cursor.next
        return cursor

    def delete_node(self, node):
        if node == self.sentinel:
            return
        node.prev.next = node.next
        node.next.prev = node.prev DoublyLinkedList def __init__(self):
        self.sentinel = Node(None)
        self.sentinel.prev = self.sentinel
        self.sentinel.next = self.sentinel

     __init__ self.sentinel = Node(None) self.sentinel self sentinel Node(None) Node None self.sentinel.prev = self.sentinel self.sentinel.prev self.sentinel self sentinel prev self.sentinel self sentinel self.sentinel.next = self.sentinel self.sentinel.next self.sentinel self sentinel next self.sentinel self sentinel self self def insert(self, val):
        node = Node(val)
        node.prev = self.sentinel
        node.next = self.sentinel.next
        self.sentinel.next.prev = node
        self.sentinel.next = node

     insert node = Node(val) node Node(val) Node val node.prev = self.sentinel node.prev node prev self.sentinel self sentinel node.next = self.sentinel.next node.next node next self.sentinel.next self.sentinel self sentinel next self.sentinel.next.prev = node self.sentinel.next.prev self.sentinel.next self.sentinel self sentinel next prev node self.sentinel.next = node self.sentinel.next self.sentinel self sentinel next node self self val val def delete(self, val):
        self.delete_node(self.search(val))

     delete self.delete_node(self.search(val)) self.delete_node self delete_node self.search(val) self.search self search val self self val val def deleteFirst(self):
        self.delete_node(self.sentinel.next)

     deleteFirst self.delete_node(self.sentinel.next) self.delete_node self delete_node self.sentinel.next self.sentinel self sentinel next self self def deleteLast(self):
        self.delete_node(self.sentinel.prev)

     deleteLast self.delete_node(self.sentinel.prev) self.delete_node self delete_node self.sentinel.prev self.sentinel self sentinel prev self self def search(self, val):
        cursor = self.sentinel.next
        while cursor != self.sentinel and cursor.val != val:
            cursor = cursor.next
        return cursor

     search cursor = self.sentinel.next cursor self.sentinel.next self.sentinel self sentinel next while cursor != self.sentinel and cursor.val != val:
            cursor = cursor.next
         cursor != self.sentinel and cursor.val != val cursor != self.sentinel cursor self.sentinel self sentinel cursor.val != val cursor.val cursor val val cursor = cursor.next cursor cursor.next cursor next return cursor cursor self self val val def delete_node(self, node):
        if node == self.sentinel:
            return
        node.prev.next = node.next
        node.next.prev = node.prev delete_node if node == self.sentinel:
            return
         node == self.sentinel node self.sentinel self sentinel 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 n = int(input()) n int(input()) int input() input linked_list = DoublyLinkedList() linked_list DoublyLinkedList() DoublyLinkedList for index in range(n):
    command = input().rstrip()
    if command[0] == 'i':
        linked_list.insert(command[7:])
    elif command[6] == 'F':
        linked_list.deleteFirst()
    elif command[6] == 'L':
        linked_list.deleteLast()
    else:
        linked_list.delete(command[7:]) index range(n) range n command = input().rstrip() command input().rstrip() ().rstrip () input rstrip if command[0] == 'i':
        linked_list.insert(command[7:])
    elif command[6] == 'F':
        linked_list.deleteFirst()
    elif command[6] == 'L':
        linked_list.deleteLast()
    else:
        linked_list.delete(command[7:]) command[0] == 'i' command[0] command 0 'i' linked_list.insert(command[7:]) linked_list.insert linked_list insert command[7:] command 7: 7 elif command[6] == 'F':
        linked_list.deleteFirst()
     command[6] == 'F' command[6] command 6 'F' linked_list.deleteFirst() linked_list.deleteFirst linked_list deleteFirst elif command[6] == 'L':
        linked_list.deleteLast()
     command[6] == 'L' command[6] command 6 'L' linked_list.deleteLast() linked_list.deleteLast linked_list deleteLast linked_list.delete(command[7:]) linked_list.delete linked_list delete command[7:] command 7: 7 node = linked_list.sentinel.next node linked_list.sentinel.next linked_list.sentinel linked_list sentinel next output = [] output [] while node != linked_list.sentinel:
    output.append(node.val)
    node = node.next node != linked_list.sentinel node linked_list.sentinel linked_list sentinel output.append(node.val) output.append output append node.val node val node = node.next node node.next node next print(" ".join(map(str, output))) print " ".join(map(str, output)) " ".join " " join map(str, output) map str output node = node.next node.next node n = int(input()) int(input()) n command = input().rstrip() input().rstrip() command linked_list = DoublyLinkedList() DoublyLinkedList() linked_list class Node:
    def __init__(self, val):
        self.val  = val
        self.prev = None
        self.next = None class Node:
    def __init__(self, val):
        self.val  = val
        self.prev = None
        self.next = None Node input = sys.stdin.readline sys.stdin.readline input output = [] [] output class DoublyLinkedList:
    def __init__(self):
        self.sentinel = Node(None)
        self.sentinel.prev = self.sentinel
        self.sentinel.next = self.sentinel

    def insert(self, val):
        node = Node(val)
        node.prev = self.sentinel
        node.next = self.sentinel.next
        self.sentinel.next.prev = node
        self.sentinel.next = node

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

    def deleteFirst(self):
        self.delete_node(self.sentinel.next)

    def deleteLast(self):
        self.delete_node(self.sentinel.prev)

    def search(self, val):
        cursor = self.sentinel.next
        while cursor != self.sentinel and cursor.val != val:
            cursor = cursor.next
        return cursor

    def delete_node(self, node):
        if node == self.sentinel:
            return
        node.prev.next = node.next
        node.next.prev = node.prev class DoublyLinkedList:
    def __init__(self):
        self.sentinel = Node(None)
        self.sentinel.prev = self.sentinel
        self.sentinel.next = self.sentinel

    def insert(self, val):
        node = Node(val)
        node.prev = self.sentinel
        node.next = self.sentinel.next
        self.sentinel.next.prev = node
        self.sentinel.next = node

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

    def deleteFirst(self):
        self.delete_node(self.sentinel.next)

    def deleteLast(self):
        self.delete_node(self.sentinel.prev)

    def search(self, val):
        cursor = self.sentinel.next
        while cursor != self.sentinel and cursor.val != val:
            cursor = cursor.next
        return cursor

    def delete_node(self, node):
        if node == self.sentinel:
            return
        node.prev.next = node.next
        node.next.prev = node.prev DoublyLinkedList node = linked_list.sentinel.next linked_list.sentinel.next node
import sys
input = sys.stdin.readline

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

class DoublyLinkedList:
    def __init__(self):
        self.sentinel = Node(None)
        self.sentinel.prev = self.sentinel
        self.sentinel.next = self.sentinel

    def insert(self, val):
        node = Node(val)
        node.prev = self.sentinel
        node.next = self.sentinel.next
        self.sentinel.next.prev = node
        self.sentinel.next = node

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

    def deleteFirst(self):
        self.delete_node(self.sentinel.next)

    def deleteLast(self):
        self.delete_node(self.sentinel.prev)

    def search(self, val):
        cursor = self.sentinel.next
        while cursor != self.sentinel and cursor.val != val:
            cursor = cursor.next
        return cursor

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

n = int(input())
linked_list = DoublyLinkedList()
for index in range(n):
    command = input().rstrip()
    if command[0] == 'i':
        linked_list.insert(command[7:])
    elif command[6] == 'F':
        linked_list.deleteFirst()
    elif command[6] == 'L':
        linked_list.deleteLast()
    else:
        linked_list.delete(command[7:])

node = linked_list.sentinel.next
output = []
while node != linked_list.sentinel:
    output.append(node.val)
    node = node.next
print(" ".join(map(str, output)))
