from collections import deque

queue = deque([])

n = int(input())

for i in range(n):
    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()

last = queue.pop()
for i in queue:
    print(i, end=" ")

print(last) from collections import deque queue = deque([]) queue deque([]) deque [] n = int(input()) n int(input()) int input() input for i in range(n):
    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() i range(n) range n 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 last = queue.pop() last queue.pop() queue.pop queue pop for i in queue:
    print(i, end=" ") i queue print(i, end=" ") print i end=" " end " " print(last) print last commands = input().split(" ") input().split(" ") commands queue = deque([]) deque([]) queue n = int(input()) int(input()) n command = commands[0] commands[0] command last = queue.pop() queue.pop() last
from collections import deque

queue = deque([])

n = int(input())

for i in range(n):
    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()

last = queue.pop()
for i in queue:
    print(i, end=" ")

print(last)