from collections import deque

n = int(input())

answer = deque()
for i in range(n):
    command = input()
    if " " in command:
        command, key = command.split()
    
    if command == "insert":
        answer.appendleft(key)
    elif command == "delete":
        if key in answer:
            answer.remove(key)
    elif command == "deleteFirst":
        answer.popleft()
    elif command == "deleteLast":
        answer.pop()

print(*answer) from collections import deque n = int(input()) n int(input()) int input() input answer = deque() answer deque() deque for i in range(n):
    command = input()
    if " " in command:
        command, key = command.split()
    
    if command == "insert":
        answer.appendleft(key)
    elif command == "delete":
        if key in answer:
            answer.remove(key)
    elif command == "deleteFirst":
        answer.popleft()
    elif command == "deleteLast":
        answer.pop() i range(n) range n command = input() command input() input if " " in command:
        command, key = command.split()
    
     " " in command " " command command, key = command.split() command command.split() command.split command split key if command == "insert":
        answer.appendleft(key)
    elif command == "delete":
        if key in answer:
            answer.remove(key)
    elif command == "deleteFirst":
        answer.popleft()
    elif command == "deleteLast":
        answer.pop() command == "insert" command "insert" answer.appendleft(key) answer.appendleft answer appendleft key elif command == "delete":
        if key in answer:
            answer.remove(key)
     command == "delete" command "delete" if key in answer:
            answer.remove(key)
     key in answer key answer answer.remove(key) answer.remove answer remove key elif command == "deleteFirst":
        answer.popleft()
     command == "deleteFirst" command "deleteFirst" answer.popleft() answer.popleft answer popleft elif command == "deleteLast":
        answer.pop() command == "deleteLast" command "deleteLast" answer.pop() answer.pop answer pop print(*answer) print *answer answer key = command.split() command.split() key command, key = command.split() command.split() command answer = deque() deque() answer n = int(input()) int(input()) n command = input() input() command
from collections import deque

n = int(input())

answer = deque()
for i in range(n):
    command = input()
    if " " in command:
        command, key = command.split()
    
    if command == "insert":
        answer.appendleft(key)
    elif command == "delete":
        if key in answer:
            answer.remove(key)
    elif command == "deleteFirst":
        answer.popleft()
    elif command == "deleteLast":
        answer.pop()

print(*answer)
