from collections import deque

DLL = deque()

n = int(input())

for i in range(n):
    Line = input().split()
    
    if Line[0] == "insert":
        DLL.appendleft(Line[1])
        
    elif Line[0] == "delete":
        try:
            DLL.remove(Line[1])
        except ValueError:
            None
    elif Line[0] == "deleteFirst":
        DLL.popleft()
    elif Line[0] == "deleteLast":
        DLL.pop()

print(" ".join(DLL)) from collections import deque DLL = deque() DLL deque() deque n = int(input()) n int(input()) int input() input for i in range(n):
    Line = input().split()
    
    if Line[0] == "insert":
        DLL.appendleft(Line[1])
        
    elif Line[0] == "delete":
        try:
            DLL.remove(Line[1])
        except ValueError:
            None
    elif Line[0] == "deleteFirst":
        DLL.popleft()
    elif Line[0] == "deleteLast":
        DLL.pop() i range(n) range n Line = input().split() Line input().split() ().split () input split if Line[0] == "insert":
        DLL.appendleft(Line[1])
        
    elif Line[0] == "delete":
        try:
            DLL.remove(Line[1])
        except ValueError:
            None
    elif Line[0] == "deleteFirst":
        DLL.popleft()
    elif Line[0] == "deleteLast":
        DLL.pop() Line[0] == "insert" Line[0] Line 0 "insert" DLL.appendleft(Line[1]) DLL.appendleft DLL appendleft Line[1] Line 1 elif Line[0] == "delete":
        try:
            DLL.remove(Line[1])
        except ValueError:
            None
     Line[0] == "delete" Line[0] Line 0 "delete" try:
            DLL.remove(Line[1])
        except ValueError:
            None
     except ValueError:
            None
     None DLL.remove(Line[1]) DLL.remove DLL remove Line[1] Line 1 elif Line[0] == "deleteFirst":
        DLL.popleft()
     Line[0] == "deleteFirst" Line[0] Line 0 "deleteFirst" DLL.popleft() DLL.popleft DLL popleft elif Line[0] == "deleteLast":
        DLL.pop() Line[0] == "deleteLast" Line[0] Line 0 "deleteLast" DLL.pop() DLL.pop DLL pop print(" ".join(DLL)) print " ".join(DLL) " ".join " " join DLL DLL = deque() deque() DLL Line = input().split() input().split() Line n = int(input()) int(input()) n
from collections import deque

DLL = deque()

n = int(input())

for i in range(n):
    Line = input().split()
    
    if Line[0] == "insert":
        DLL.appendleft(Line[1])
        
    elif Line[0] == "delete":
        try:
            DLL.remove(Line[1])
        except ValueError:
            None
    elif Line[0] == "deleteFirst":
        DLL.popleft()
    elif Line[0] == "deleteLast":
        DLL.pop()

print(" ".join(DLL))
