from collections import deque

# 命令数入力
n = int(input())
# 命令入力
# order_list = [input().split() for i in range(n)]


# 双方向連結リスト
doubly_linked_list = deque()

for i in range(n):
    
    order = input().split()
    
    if order[0] == "insert":
        doubly_linked_list.appendleft(order[1])
    
    elif order[0] == "delete":
        if order[1] in doubly_linked_list:
            doubly_linked_list.remove(order[1])
    
    elif order[0] =="deleteFirst":
        doubly_linked_list.popleft()
    
    elif order[0] == "deleteLast":
        doubly_linked_list.pop()
        
# 最終結果出力
print(*doubly_linked_list) from collections import deque n = int(input()) n int(input()) int input() input doubly_linked_list = deque() doubly_linked_list deque() deque for i in range(n):
    
    order = input().split()
    
    if order[0] == "insert":
        doubly_linked_list.appendleft(order[1])
    
    elif order[0] == "delete":
        if order[1] in doubly_linked_list:
            doubly_linked_list.remove(order[1])
    
    elif order[0] =="deleteFirst":
        doubly_linked_list.popleft()
    
    elif order[0] == "deleteLast":
        doubly_linked_list.pop()
        
# 最終結果出力 i range(n) range n order = input().split() order input().split() ().split () input split if order[0] == "insert":
        doubly_linked_list.appendleft(order[1])
    
    elif order[0] == "delete":
        if order[1] in doubly_linked_list:
            doubly_linked_list.remove(order[1])
    
    elif order[0] =="deleteFirst":
        doubly_linked_list.popleft()
    
    elif order[0] == "deleteLast":
        doubly_linked_list.pop()
        
# 最終結果出力 order[0] == "insert" order[0] order 0 "insert" doubly_linked_list.appendleft(order[1]) doubly_linked_list.appendleft doubly_linked_list appendleft order[1] order 1 elif order[0] == "delete":
        if order[1] in doubly_linked_list:
            doubly_linked_list.remove(order[1])
    
     order[0] == "delete" order[0] order 0 "delete" if order[1] in doubly_linked_list:
            doubly_linked_list.remove(order[1])
    
     order[1] in doubly_linked_list order[1] order 1 doubly_linked_list doubly_linked_list.remove(order[1]) doubly_linked_list.remove doubly_linked_list remove order[1] order 1 elif order[0] =="deleteFirst":
        doubly_linked_list.popleft()
    
     order[0] =="deleteFirst" order[0] order 0 "deleteFirst" doubly_linked_list.popleft() doubly_linked_list.popleft doubly_linked_list popleft elif order[0] == "deleteLast":
        doubly_linked_list.pop()
        
# 最終結果出力 order[0] == "deleteLast" order[0] order 0 "deleteLast" doubly_linked_list.pop() doubly_linked_list.pop doubly_linked_list pop print(*doubly_linked_list) print *doubly_linked_list doubly_linked_list doubly_linked_list = deque() deque() doubly_linked_list order = input().split() input().split() order n = int(input()) int(input()) n
from collections import deque

# 命令数入力
n = int(input())
# 命令入力
# order_list = [input().split() for i in range(n)]


# 双方向連結リスト
doubly_linked_list = deque()

for i in range(n):
    
    order = input().split()
    
    if order[0] == "insert":
        doubly_linked_list.appendleft(order[1])
    
    elif order[0] == "delete":
        if order[1] in doubly_linked_list:
            doubly_linked_list.remove(order[1])
    
    elif order[0] =="deleteFirst":
        doubly_linked_list.popleft()
    
    elif order[0] == "deleteLast":
        doubly_linked_list.pop()
        
# 最終結果出力
print(*doubly_linked_list)
