# ALDS1_3_C.py
'''
本来はlinkedList を自前実装する必要がありそうだが、Python だとDequeで実装できる。
'''
from collections import deque
N = int(input())
linkedList = deque([])
for i in range(N):
    command = input().split()
    if command[0] == "insert":
        linkedList.appendleft(command[1])
    elif command[0] == "delete":
        if command[1] in linkedList:
                linkedList.remove(command[1])
    elif command[0] == "deleteFirst":
        linkedList.popleft()
    elif command[0] == "deleteLast":
        linkedList.pop()
print(" ".join(list(linkedList))) '''
本来はlinkedList を自前実装する必要がありそうだが、Python だとDequeで実装できる。
''' from collections import deque N = int(input()) N int(input()) int input() input linkedList = deque([]) linkedList deque([]) deque [] for i in range(N):
    command = input().split()
    if command[0] == "insert":
        linkedList.appendleft(command[1])
    elif command[0] == "delete":
        if command[1] in linkedList:
                linkedList.remove(command[1])
    elif command[0] == "deleteFirst":
        linkedList.popleft()
    elif command[0] == "deleteLast":
        linkedList.pop() i range(N) range N command = input().split() command input().split() ().split () input split if command[0] == "insert":
        linkedList.appendleft(command[1])
    elif command[0] == "delete":
        if command[1] in linkedList:
                linkedList.remove(command[1])
    elif command[0] == "deleteFirst":
        linkedList.popleft()
    elif command[0] == "deleteLast":
        linkedList.pop() command[0] == "insert" command[0] command 0 "insert" linkedList.appendleft(command[1]) linkedList.appendleft linkedList appendleft command[1] command 1 elif command[0] == "delete":
        if command[1] in linkedList:
                linkedList.remove(command[1])
     command[0] == "delete" command[0] command 0 "delete" if command[1] in linkedList:
                linkedList.remove(command[1])
     command[1] in linkedList command[1] command 1 linkedList linkedList.remove(command[1]) linkedList.remove linkedList remove command[1] command 1 elif command[0] == "deleteFirst":
        linkedList.popleft()
     command[0] == "deleteFirst" command[0] command 0 "deleteFirst" linkedList.popleft() linkedList.popleft linkedList popleft elif command[0] == "deleteLast":
        linkedList.pop() command[0] == "deleteLast" command[0] command 0 "deleteLast" linkedList.pop() linkedList.pop linkedList pop print(" ".join(list(linkedList))) print " ".join(list(linkedList)) " ".join " " join list(linkedList) list linkedList N = int(input()) int(input()) N command = input().split() input().split() command linkedList = deque([]) deque([]) linkedList
# ALDS1_3_C.py
'''
本来はlinkedList を自前実装する必要がありそうだが、Python だとDequeで実装できる。
'''
from collections import deque
N = int(input())
linkedList = deque([])
for i in range(N):
    command = input().split()
    if command[0] == "insert":
        linkedList.appendleft(command[1])
    elif command[0] == "delete":
        if command[1] in linkedList:
                linkedList.remove(command[1])
    elif command[0] == "deleteFirst":
        linkedList.popleft()
    elif command[0] == "deleteLast":
        linkedList.pop()
print(" ".join(list(linkedList)))
