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

class DoublyLinkedList:
    def __init__(self):
        self.nil = Node(None)
        self.nil.prev = self.nil
        self.nil.next = self.nil
    
    def insert(self,key):
        new = Node(key)
        new.next = self.nil.next
        self.nil.next.prev = new
        self.nil.next = new
        new.prev = self.nil
    
    def listSearch(self,key):
        cur = self.nil.next
        while cur != self.nil and cur.key != key:
            cur = cur.next
        return cur
    
    def deleteNode(self, t):
        if t == self.nil:
            return
        t.prev.next = t.next
        t.next.prev = t.prev

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

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

    def deleteKey(self, key):
        self.deleteNode(self.listSearch(key))
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline
    n = int(input())
    d = DoublyLinkedList()
    for _ in range(n):
        c = input().rstrip()
        if c[0] == "i":
            d.insert(c[7:])
        elif c[6] == "F":
            d.deleteFirst()
        elif c[6] =="L":
            d.deleteLast()
        else:
            d.deleteKey(c[7:])
    ans = []
    cur = d.nil.next
    while cur != d.nil:
        ans.append(cur.key)
        cur = cur.next
    print(" ".join(ans)) class Node:
    def __init__(self,key):
        self.key = key
        self.prev = None
        self.next = None Node def __init__(self,key):
        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 key class DoublyLinkedList:
    def __init__(self):
        self.nil = Node(None)
        self.nil.prev = self.nil
        self.nil.next = self.nil
    
    def insert(self,key):
        new = Node(key)
        new.next = self.nil.next
        self.nil.next.prev = new
        self.nil.next = new
        new.prev = self.nil
    
    def listSearch(self,key):
        cur = self.nil.next
        while cur != self.nil and cur.key != key:
            cur = cur.next
        return cur
    
    def deleteNode(self, t):
        if t == self.nil:
            return
        t.prev.next = t.next
        t.next.prev = t.prev

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

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

    def deleteKey(self, key):
        self.deleteNode(self.listSearch(key)) DoublyLinkedList def __init__(self):
        self.nil = Node(None)
        self.nil.prev = self.nil
        self.nil.next = self.nil
    
     __init__ self.nil = Node(None) self.nil self nil Node(None) Node None self.nil.prev = self.nil self.nil.prev self.nil self nil prev self.nil self nil self.nil.next = self.nil self.nil.next self.nil self nil next self.nil self nil self self def insert(self,key):
        new = Node(key)
        new.next = self.nil.next
        self.nil.next.prev = new
        self.nil.next = new
        new.prev = self.nil
    
     insert new = Node(key) new Node(key) Node key new.next = self.nil.next new.next new next self.nil.next self.nil self nil next self.nil.next.prev = new self.nil.next.prev self.nil.next self.nil self nil next prev new self.nil.next = new self.nil.next self.nil self nil next new new.prev = self.nil new.prev new prev self.nil self nil self self key key def listSearch(self,key):
        cur = self.nil.next
        while cur != self.nil and cur.key != key:
            cur = cur.next
        return cur
    
     listSearch cur = self.nil.next cur self.nil.next self.nil self nil next while cur != self.nil and cur.key != key:
            cur = cur.next
         cur != self.nil and cur.key != key cur != self.nil cur self.nil self nil cur.key != key cur.key cur key key cur = cur.next cur cur.next cur next return cur cur self self key key def deleteNode(self, t):
        if t == self.nil:
            return
        t.prev.next = t.next
        t.next.prev = t.prev

     deleteNode if t == self.nil:
            return
         t == self.nil t self.nil self nil return t.prev.next = t.next t.prev.next t.prev t prev next t.next t next t.next.prev = t.prev t.next.prev t.next t next prev t.prev t prev self self t t 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):
        self.deleteNode(self.listSearch(key)) deleteKey self.deleteNode(self.listSearch(key)) self.deleteNode self deleteNode self.listSearch(key) self.listSearch self listSearch key self self key key if __name__ == '__main__':
    import sys
    input = sys.stdin.readline
    n = int(input())
    d = DoublyLinkedList()
    for _ in range(n):
        c = input().rstrip()
        if c[0] == "i":
            d.insert(c[7:])
        elif c[6] == "F":
            d.deleteFirst()
        elif c[6] =="L":
            d.deleteLast()
        else:
            d.deleteKey(c[7:])
    ans = []
    cur = d.nil.next
    while cur != d.nil:
        ans.append(cur.key)
        cur = cur.next
    print(" ".join(ans)) __name__ == '__main__' __name__ '__main__' import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline n = int(input()) n int(input()) int input() input d = DoublyLinkedList() d DoublyLinkedList() DoublyLinkedList for _ in range(n):
        c = input().rstrip()
        if c[0] == "i":
            d.insert(c[7:])
        elif c[6] == "F":
            d.deleteFirst()
        elif c[6] =="L":
            d.deleteLast()
        else:
            d.deleteKey(c[7:])
     _ range(n) range n c = input().rstrip() c input().rstrip() ().rstrip () input rstrip if c[0] == "i":
            d.insert(c[7:])
        elif c[6] == "F":
            d.deleteFirst()
        elif c[6] =="L":
            d.deleteLast()
        else:
            d.deleteKey(c[7:])
     c[0] == "i" c[0] c 0 "i" d.insert(c[7:]) d.insert d insert c[7:] c 7: 7 elif c[6] == "F":
            d.deleteFirst()
         c[6] == "F" c[6] c 6 "F" d.deleteFirst() d.deleteFirst d deleteFirst elif c[6] =="L":
            d.deleteLast()
         c[6] =="L" c[6] c 6 "L" d.deleteLast() d.deleteLast d deleteLast d.deleteKey(c[7:]) d.deleteKey d deleteKey c[7:] c 7: 7 ans = [] ans [] cur = d.nil.next cur d.nil.next d.nil d nil next while cur != d.nil:
        ans.append(cur.key)
        cur = cur.next
     cur != d.nil cur d.nil d nil ans.append(cur.key) ans.append ans append cur.key cur key cur = cur.next cur cur.next cur next print(" ".join(ans)) print " ".join(ans) " ".join " " join ans input = sys.stdin.readline sys.stdin.readline input class Node:
    def __init__(self,key):
        self.key = key
        self.prev = None
        self.next = None class Node:
    def __init__(self,key):
        self.key = key
        self.prev = None
        self.next = None Node cur = d.nil.next d.nil.next cur c = input().rstrip() input().rstrip() c ans = [] [] ans cur = cur.next cur.next cur class DoublyLinkedList:
    def __init__(self):
        self.nil = Node(None)
        self.nil.prev = self.nil
        self.nil.next = self.nil
    
    def insert(self,key):
        new = Node(key)
        new.next = self.nil.next
        self.nil.next.prev = new
        self.nil.next = new
        new.prev = self.nil
    
    def listSearch(self,key):
        cur = self.nil.next
        while cur != self.nil and cur.key != key:
            cur = cur.next
        return cur
    
    def deleteNode(self, t):
        if t == self.nil:
            return
        t.prev.next = t.next
        t.next.prev = t.prev

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

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

    def deleteKey(self, key):
        self.deleteNode(self.listSearch(key)) class DoublyLinkedList:
    def __init__(self):
        self.nil = Node(None)
        self.nil.prev = self.nil
        self.nil.next = self.nil
    
    def insert(self,key):
        new = Node(key)
        new.next = self.nil.next
        self.nil.next.prev = new
        self.nil.next = new
        new.prev = self.nil
    
    def listSearch(self,key):
        cur = self.nil.next
        while cur != self.nil and cur.key != key:
            cur = cur.next
        return cur
    
    def deleteNode(self, t):
        if t == self.nil:
            return
        t.prev.next = t.next
        t.next.prev = t.prev

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

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

    def deleteKey(self, key):
        self.deleteNode(self.listSearch(key)) DoublyLinkedList n = int(input()) int(input()) n d = DoublyLinkedList() DoublyLinkedList() d
class Node:
    def __init__(self,key):
        self.key = key
        self.prev = None
        self.next = None

class DoublyLinkedList:
    def __init__(self):
        self.nil = Node(None)
        self.nil.prev = self.nil
        self.nil.next = self.nil
    
    def insert(self,key):
        new = Node(key)
        new.next = self.nil.next
        self.nil.next.prev = new
        self.nil.next = new
        new.prev = self.nil
    
    def listSearch(self,key):
        cur = self.nil.next
        while cur != self.nil and cur.key != key:
            cur = cur.next
        return cur
    
    def deleteNode(self, t):
        if t == self.nil:
            return
        t.prev.next = t.next
        t.next.prev = t.prev

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

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

    def deleteKey(self, key):
        self.deleteNode(self.listSearch(key))
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline
    n = int(input())
    d = DoublyLinkedList()
    for _ in range(n):
        c = input().rstrip()
        if c[0] == "i":
            d.insert(c[7:])
        elif c[6] == "F":
            d.deleteFirst()
        elif c[6] =="L":
            d.deleteLast()
        else:
            d.deleteKey(c[7:])
    ans = []
    cur = d.nil.next
    while cur != d.nil:
        ans.append(cur.key)
        cur = cur.next
    print(" ".join(ans))
