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