from collections import deque

queue = deque([])

for _ in range(int(input())):
    commands = input().split(" ")
    command = commands[0]
    if command == "insert":
        queue.appendleft(commands[1])
    elif command == "delete":
        try:
            queue.remove(commands[1])
        except ValueError:
            pass
    elif command == "deleteFirst":
        queue.popleft()
    elif command == "deleteLast":
        queue.pop()

print(" ".join(queue)) from collections import deque queue = deque([]) queue deque([]) deque [] for _ in range(int(input())):
    commands = input().split(" ")
    command = commands[0]
    if command == "insert":
        queue.appendleft(commands[1])
    elif command == "delete":
        try:
            queue.remove(commands[1])
        except ValueError:
            pass
    elif command == "deleteFirst":
        queue.popleft()
    elif command == "deleteLast":
        queue.pop() _ range(int(input())) range int(input()) int input() input commands = input().split(" ") commands input().split(" ") ().split () input split " " command = commands[0] command commands[0] commands 0 if command == "insert":
        queue.appendleft(commands[1])
    elif command == "delete":
        try:
            queue.remove(commands[1])
        except ValueError:
            pass
    elif command == "deleteFirst":
        queue.popleft()
    elif command == "deleteLast":
        queue.pop() command == "insert" command "insert" queue.appendleft(commands[1]) queue.appendleft queue appendleft commands[1] commands 1 elif command == "delete":
        try:
            queue.remove(commands[1])
        except ValueError:
            pass
     command == "delete" command "delete" try:
            queue.remove(commands[1])
        except ValueError:
            pass
     except ValueError:
            pass
     queue.remove(commands[1]) queue.remove queue remove commands[1] commands 1 elif command == "deleteFirst":
        queue.popleft()
     command == "deleteFirst" command "deleteFirst" queue.popleft() queue.popleft queue popleft elif command == "deleteLast":
        queue.pop() command == "deleteLast" command "deleteLast" queue.pop() queue.pop queue pop print(" ".join(queue)) print " ".join(queue) " ".join " " join queue command = commands[0] commands[0] command queue = deque([]) deque([]) queue commands = input().split(" ") input().split(" ") commands
from collections import deque

queue = deque([])

for _ in range(int(input())):
    commands = input().split(" ")
    command = commands[0]
    if command == "insert":
        queue.appendleft(commands[1])
    elif command == "delete":
        try:
            queue.remove(commands[1])
        except ValueError:
            pass
    elif command == "deleteFirst":
        queue.popleft()
    elif command == "deleteLast":
        queue.pop()

print(" ".join(queue))