#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":
            if o[1] in dll:
                dll.remove(o[1])
            #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() NEXT = 2 NEXT 2 DATA = 1 DATA 1 PREV = 0 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":
            if o[1] in dll:
                dll.remove(o[1])
            #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 dll_processor front = None front None end = None end None dll = deque([]) dll deque([]) deque [] for o in operations:
        if o[0] == "insert":
            dll.appendleft(o[1])
            #front, end = insert(front, end, o[1])
        elif o[0] == "delete":
            if o[1] in dll:
                dll.remove(o[1])
            #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))
        
     o operations if o[0] == "insert":
            dll.appendleft(o[1])
            #front, end = insert(front, end, o[1])
        elif o[0] == "delete":
            if o[1] in dll:
                dll.remove(o[1])
            #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))
        
     o[0] == "insert" o[0] o 0 "insert" dll.appendleft(o[1]) dll.appendleft dll appendleft o[1] o 1 elif o[0] == "delete":
            if o[1] in dll:
                dll.remove(o[1])
            #front, end = delete(front, end, o[1])
         o[0] == "delete" o[0] o 0 "delete" if o[1] in dll:
                dll.remove(o[1])
            #front, end = delete(front, end, o[1])
         o[1] in dll o[1] o 1 dll dll.remove(o[1]) dll.remove dll remove o[1] o 1 elif o[0] == "deleteFirst":
            dll.popleft()
            #front, end = delete_first(front, end)
         o[0] == "deleteFirst" o[0] o 0 "deleteFirst" dll.popleft() dll.popleft dll popleft elif o[0] == "deleteLast":
            dll.pop()
            #front, end = delete_last(front, end)
        #print(get_list(front))
        
     o[0] == "deleteLast" o[0] o 0 "deleteLast" dll.pop() dll.pop dll pop return dll dll operations operations 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 get_list if not front:
        return []
    
     not front front return [] [] l = [] l [] target = front target front while True:
        l.append(target[DATA])
        if not target[NEXT]:
            break
        target = target[NEXT]
     True l.append(target[DATA]) l.append l append target[DATA] target DATA if not target[NEXT]:
            break
         not target[NEXT] target[NEXT] target NEXT break target = target[NEXT] target target[NEXT] target NEXT return l l front front def insert(front, end, target):
    node = [None, target, None]
    if front:
        front[PREV] = node
        node[NEXT] = front
        return node, end
    else:
        return node, node
     insert node = [None, target, None] node [None, target, None] None target None if front:
        front[PREV] = node
        node[NEXT] = front
        return node, end
    else:
        return node, node
     front front[PREV] = node front[PREV] front PREV node node[NEXT] = front node[NEXT] node NEXT front return node, end return node, end node end return node, node return node, node node node front front end end target target 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
     delete delete_node = front delete_node front while not delete_node[DATA] == target:
        delete_node = delete_node[NEXT]
        if delete_node == None:
            return front, end

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

     delete_node == None delete_node None return front, end return front, end 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
     delete_node[PREV] == None delete_node[PREV] delete_node PREV None delete_node[NEXT][PREV] = None delete_node[NEXT][PREV] [NEXT] delete_node NEXT PREV None return delete_node[NEXT], end return delete_node[NEXT], end delete_node[NEXT] delete_node NEXT end elif delete_node[NEXT] == None:
        delete_node[PREV][NEXT] = None
        return front, delete_node[PREV]
     delete_node[NEXT] == None delete_node[NEXT] delete_node NEXT None delete_node[PREV][NEXT] = None delete_node[PREV][NEXT] [PREV] delete_node PREV NEXT None return front, delete_node[PREV] return front, delete_node[PREV] front delete_node[PREV] delete_node PREV delete_node[NEXT][PREV] = delete_node[PREV] delete_node[NEXT][PREV] [NEXT] delete_node NEXT PREV delete_node[PREV] delete_node PREV delete_node[PREV][NEXT] = delete_node[NEXT] delete_node[PREV][NEXT] [PREV] delete_node PREV NEXT delete_node[NEXT] delete_node NEXT return front, end return front, end front end front front end end target target def delete_last(front, end):
    
    if not end[PREV]:
        return None, None
    else:
        end[PREV][NEXT] = None
        return front, end[PREV]
     delete_last if not end[PREV]:
        return None, None
    else:
        end[PREV][NEXT] = None
        return front, end[PREV]
     not end[PREV] end[PREV] end PREV return None, None return None, None None None end[PREV][NEXT] = None end[PREV][NEXT] [PREV] end PREV NEXT None return front, end[PREV] return front, end[PREV] front end[PREV] end PREV front front end end def delete_first(front, end):
    
    if not front[NEXT]:
        return None, None
    else:
        front[NEXT][PREV] = None
        return front[NEXT], end delete_first if not front[NEXT]:
        return None, None
    else:
        front[NEXT][PREV] = None
        return front[NEXT], end not front[NEXT] front[NEXT] front NEXT return None, None return None, None None None front[NEXT][PREV] = None front[NEXT][PREV] [NEXT] front NEXT PREV None return front[NEXT], end return front[NEXT], end front[NEXT] front NEXT end front front end end def main():
    n_list = int(input())
    target_list = [input().split() for i in range(n_list)]
    print(*dll_processor(target_list))
     main n_list = int(input()) n_list int(input()) int input() input input().split() for i in range(n_list) for i in range(n_list) i range(n_list) range n_list for i in range(n_list) input().split() ().split () input split target_list = [input().split() for i in range(n_list)] target_list [input().split() for i in range(n_list)] print(*dll_processor(target_list)) print *dll_processor(target_list) dll_processor(target_list) dll_processor target_list if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main DATA = 1 1 DATA 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 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 get_list def delete_last(front, end):
    
    if not end[PREV]:
        return None, None
    else:
        end[PREV][NEXT] = None
        return front, end[PREV]
     def delete_last(front, end):
    
    if not end[PREV]:
        return None, None
    else:
        end[PREV][NEXT] = None
        return front, end[PREV]
     delete_last def delete_first(front, end):
    
    if not front[NEXT]:
        return None, None
    else:
        front[NEXT][PREV] = None
        return front[NEXT], end def delete_first(front, end):
    
    if not front[NEXT]:
        return None, None
    else:
        front[NEXT][PREV] = None
        return front[NEXT], end delete_first 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(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
     delete PREV = 0 0 PREV 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 insert(front, end, target):
    node = [None, target, None]
    if front:
        front[PREV] = node
        node[NEXT] = front
        return node, end
    else:
        return node, node
     insert 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":
            if o[1] in dll:
                dll.remove(o[1])
            #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 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":
            if o[1] in dll:
                dll.remove(o[1])
            #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 dll_processor NEXT = 2 2 NEXT def main():
    n_list = int(input())
    target_list = [input().split() for i in range(n_list)]
    print(*dll_processor(target_list))
     def main():
    n_list = int(input())
    target_list = [input().split() for i in range(n_list)]
    print(*dll_processor(target_list))
     main
#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":
            if o[1] in dll:
                dll.remove(o[1])
            #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()