from collections import deque

n = int(input())

linked_list = deque([])

for _ in range(n):
    command = input()

    if "insert" in command:
        x = command.split()[-1]
        linked_list.appendleft(x)
    elif command == "deleteFirst":
        linked_list.popleft()
    elif command == "deleteLast":
        linked_list.pop()
    elif "delete" in command:
        x = command.split()[-1]
        if x in linked_list:
            linked_list.remove(x)

print(*linked_list)
 from collections import deque n = int(input()) n int(input()) int input() input linked_list = deque([]) linked_list deque([]) deque [] for _ in range(n):
    command = input()

    if "insert" in command:
        x = command.split()[-1]
        linked_list.appendleft(x)
    elif command == "deleteFirst":
        linked_list.popleft()
    elif command == "deleteLast":
        linked_list.pop()
    elif "delete" in command:
        x = command.split()[-1]
        if x in linked_list:
            linked_list.remove(x) _ range(n) range n command = input() command input() input if "insert" in command:
        x = command.split()[-1]
        linked_list.appendleft(x)
    elif command == "deleteFirst":
        linked_list.popleft()
    elif command == "deleteLast":
        linked_list.pop()
    elif "delete" in command:
        x = command.split()[-1]
        if x in linked_list:
            linked_list.remove(x) "insert" in command "insert" command x = command.split()[-1] x command.split()[-1] command.split() command.split command split -1 linked_list.appendleft(x) linked_list.appendleft linked_list appendleft x elif command == "deleteFirst":
        linked_list.popleft()
     command == "deleteFirst" command "deleteFirst" linked_list.popleft() linked_list.popleft linked_list popleft elif command == "deleteLast":
        linked_list.pop()
     command == "deleteLast" command "deleteLast" linked_list.pop() linked_list.pop linked_list pop elif "delete" in command:
        x = command.split()[-1]
        if x in linked_list:
            linked_list.remove(x) "delete" in command "delete" command x = command.split()[-1] x command.split()[-1] command.split() command.split command split -1 if x in linked_list:
            linked_list.remove(x) x in linked_list x linked_list linked_list.remove(x) linked_list.remove linked_list remove x print(*linked_list) print *linked_list linked_list n = int(input()) int(input()) n x = command.split()[-1] command.split()[-1] x linked_list = deque([]) deque([]) linked_list command = input() input() command x = command.split()[-1] command.split()[-1] x
from collections import deque

n = int(input())

linked_list = deque([])

for _ in range(n):
    command = input()

    if "insert" in command:
        x = command.split()[-1]
        linked_list.appendleft(x)
    elif command == "deleteFirst":
        linked_list.popleft()
    elif command == "deleteLast":
        linked_list.pop()
    elif "delete" in command:
        x = command.split()[-1]
        if x in linked_list:
            linked_list.remove(x)

print(*linked_list)

