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())

    dll = DoublyLinkedList()

    for _ in range(n):
        '''
        以下のようにcomとkeyに分けるとTimeLimitExceededになるので、comだけで処理しました
        (別のいい方法があれば教えて欲しいです)
        com, *key = input().split()
        この場合keyがリストになるので、com[7:]をkey[0]で置き換える必要があります。
        (xがない命令ではkey=[]となるだけ)
        '''
        com = input().rstrip()
        # 以下、本と順番など多少異なります
        if com[0] == 'i':
            dll.insert(com[7:])
        elif com[6] == 'F':
            dll.deleteFirst()
        elif com[6] == 'L':
            dll.deleteLast()
        else:
            dll.deleteKey(com[7:])

    cur = dll.nil.next
    ans = []
    while cur != dll.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())

    dll = DoublyLinkedList()

    for _ in range(n):
        '''
        以下のようにcomとkeyに分けるとTimeLimitExceededになるので、comだけで処理しました
        (別のいい方法があれば教えて欲しいです)
        com, *key = input().split()
        この場合keyがリストになるので、com[7:]をkey[0]で置き換える必要があります。
        (xがない命令ではkey=[]となるだけ)
        '''
        com = input().rstrip()
        # 以下、本と順番など多少異なります
        if com[0] == 'i':
            dll.insert(com[7:])
        elif com[6] == 'F':
            dll.deleteFirst()
        elif com[6] == 'L':
            dll.deleteLast()
        else:
            dll.deleteKey(com[7:])

    cur = dll.nil.next
    ans = []
    while cur != dll.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 dll = DoublyLinkedList() dll DoublyLinkedList() DoublyLinkedList for _ in range(n):
        '''
        以下のようにcomとkeyに分けるとTimeLimitExceededになるので、comだけで処理しました
        (別のいい方法があれば教えて欲しいです)
        com, *key = input().split()
        この場合keyがリストになるので、com[7:]をkey[0]で置き換える必要があります。
        (xがない命令ではkey=[]となるだけ)
        '''
        com = input().rstrip()
        # 以下、本と順番など多少異なります
        if com[0] == 'i':
            dll.insert(com[7:])
        elif com[6] == 'F':
            dll.deleteFirst()
        elif com[6] == 'L':
            dll.deleteLast()
        else:
            dll.deleteKey(com[7:])

     _ range(n) range n '''
        以下のようにcomとkeyに分けるとTimeLimitExceededになるので、comだけで処理しました
        (別のいい方法があれば教えて欲しいです)
        com, *key = input().split()
        この場合keyがリストになるので、com[7:]をkey[0]で置き換える必要があります。
        (xがない命令ではkey=[]となるだけ)
        ''' com = input().rstrip() com input().rstrip() ().rstrip () input rstrip if com[0] == 'i':
            dll.insert(com[7:])
        elif com[6] == 'F':
            dll.deleteFirst()
        elif com[6] == 'L':
            dll.deleteLast()
        else:
            dll.deleteKey(com[7:])

     com[0] == 'i' com[0] com 0 'i' dll.insert(com[7:]) dll.insert dll insert com[7:] com 7: 7 elif com[6] == 'F':
            dll.deleteFirst()
         com[6] == 'F' com[6] com 6 'F' dll.deleteFirst() dll.deleteFirst dll deleteFirst elif com[6] == 'L':
            dll.deleteLast()
         com[6] == 'L' com[6] com 6 'L' dll.deleteLast() dll.deleteLast dll deleteLast dll.deleteKey(com[7:]) dll.deleteKey dll deleteKey com[7:] com 7: 7 cur = dll.nil.next cur dll.nil.next dll.nil dll nil next ans = [] ans [] while cur != dll.nil:
        ans.append(cur.key)
        cur = cur.next

     cur != dll.nil cur dll.nil dll 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 n = int(input()) int(input()) n com = input().rstrip() input().rstrip() com ans = [] [] ans 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 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 cur = dll.nil.next dll.nil.next cur cur = cur.next cur.next cur dll = DoublyLinkedList() DoublyLinkedList() dll
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())

    dll = DoublyLinkedList()

    for _ in range(n):
        '''
        以下のようにcomとkeyに分けるとTimeLimitExceededになるので、comだけで処理しました
        (別のいい方法があれば教えて欲しいです)
        com, *key = input().split()
        この場合keyがリストになるので、com[7:]をkey[0]で置き換える必要があります。
        (xがない命令ではkey=[]となるだけ)
        '''
        com = input().rstrip()
        # 以下、本と順番など多少異なります
        if com[0] == 'i':
            dll.insert(com[7:])
        elif com[6] == 'F':
            dll.deleteFirst()
        elif com[6] == 'L':
            dll.deleteLast()
        else:
            dll.deleteKey(com[7:])

    cur = dll.nil.next
    ans = []
    while cur != dll.nil:
        ans.append(cur.key)
        cur = cur.next

    print(' '.join(ans))
