### BUGGY CODE ###

#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_C&lang=jp
#???????????£????????????
#??¬?????????????????¬????????§????????¨???????????????????????????dummy????????????????????¨??§???????????????????????????????????§??????
def dll_processor(operations):
    dll = Doubly_Linked_List()
    
    for o in operations:
        opcode = o[0]
        if opcode == "insert":
            dll.insert(o[1])
        elif opcode == "delete":
            dll.delete(o[1])
        elif opcode == "deleteFirst":
            dll.deleteFirst()
        elif opcode == "deleteLast":
            dll.deleteLast()
        #print(dll.get_list())
    return dll.get_list()

class Doubly_Linked_List:
    
    def __init__(self):
        self.next = None
        self.prev = None
        self.data = "dummy"

    def get_list(self):
        first = self
        while first.prev:
            first = first.prev
            
        target = first
        l = [target.data]
        while target.next:
            if not target.next.data == "dummy":
                l.append(target.next.data)
            target = target.next
        return l
    
    def insert(self, x):
        
        first = self
        while first.prev:
            first = first.prev

        first.prev = Doubly_Linked_List()#???????????????
        first.prev.next = first
        first.prev.data = x

    def deleteFirst(self):
        first = self

        while first.prev:
            first = first.prev

        if first.data == "dummy" :
            first.next = first.next.next
            first.next.last = first
        else:
            first.next.prev = None
        
    def deleteLast(self):
        last = self
        
        while last.next:
            last = last.next

        if last.data == "dummy":
            last.prev = last.prev.prev
            if last.prev:
                last.prev.next = last
        else:
            last.prev.next = None
        
    def delete(self, x):
        first = self
        while first.prev:
            first = first.prev

        target = first
        while not target.data == x:
            if target.next:
                target = target.next
            else:
                return
    
        if target.prev == None:
            target.next.prev = None
        elif target.next == None:
            target.prev.next = None
        else:
            target.next.prev = target.prev
            target.prev.next = target.next

def main():
    n_list = int(input())
    target_list = [input().split() for i in range(n_list)]
    print(*dll_processor(target_list))
if __name__ == "__main__":
    main()

### FIXED CODE ###

#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_C&lang=jp
#???????????£????????????

NEXT = 2
DATA = 1
PREV = 0
from collections import deque
def dll_processor(operations):
    
    front = None
    end = None
    dll = deque([])
    for o in operations:
        if o[0] == "insert":
            dll.appendleft(o[1])
            #front, end = insert(front, end, o[1])
        elif o[0] == "delete":
            try:
                dll.remove(o[1])
            except:
                pass
            #front, end = delete(front, end, o[1])
        elif o[0] == "deleteFirst":
            dll.popleft()
            #front, end = delete_first(front, end)
        elif o[0] == "deleteLast":
            dll.pop()
            #front, end = delete_last(front, end)
        #print(get_list(front))
        
    return dll

def get_list(front):
    if not front:
        return []
    
    l = []
    target = front
    while True:
        l.append(target[DATA])
        if not target[NEXT]:
            break
        target = target[NEXT]
    return l

def insert(front, end, target):
    node = [None, target, None]
    if front:
        front[PREV] = node
        node[NEXT] = front
        return node, end
    else:
        return node, node
    
def delete(front, end,target):

    delete_node = front
    while not delete_node[DATA] == target:
        delete_node = delete_node[NEXT]
        if delete_node == None:
            return front, end

    if delete_node[PREV] == None:
        delete_node[NEXT][PREV] = None
        return delete_node[NEXT], end
    elif delete_node[NEXT] == None:
        delete_node[PREV][NEXT] = None
        return front, delete_node[PREV]
    else:
        delete_node[NEXT][PREV] = delete_node[PREV]
        delete_node[PREV][NEXT] = delete_node[NEXT]
        return front, end
    
def delete_last(front, end):
    
    if not end[PREV]:
        return None, None
    else:
        end[PREV][NEXT] = None
        return front, end[PREV]
    
def delete_first(front, end):
    
    if not front[NEXT]:
        return None, None
    else:
        front[NEXT][PREV] = None
        return front[NEXT], end

def main():
    n_list = int(input())
    target_list = [input().split() for i in range(n_list)]
    print(*dll_processor(target_list))
    
if __name__ == "__main__":
    main()