from collections import deque


deq = deque()
n = int(input())
for _ in range(n):
    operation = input()
    if operation == "deleteFirst":
        deq.popleft()
    elif operation == "deleteLast":
        deq.pop()
    
    else:
        command, value = operation.split()
        if command == "insert":
            deq.appendleft(int(value))
        elif command == "delete":
            try:
                deq.remove(int(value))
            except ValueError:
                pass

print(*deq)
 from collections import deque deq = deque() deq deque() deque n = int(input()) n int(input()) int input() input for _ in range(n):
    operation = input()
    if operation == "deleteFirst":
        deq.popleft()
    elif operation == "deleteLast":
        deq.pop()
    
    else:
        command, value = operation.split()
        if command == "insert":
            deq.appendleft(int(value))
        elif command == "delete":
            try:
                deq.remove(int(value))
            except ValueError:
                pass _ range(n) range n operation = input() operation input() input if operation == "deleteFirst":
        deq.popleft()
    elif operation == "deleteLast":
        deq.pop()
    
    else:
        command, value = operation.split()
        if command == "insert":
            deq.appendleft(int(value))
        elif command == "delete":
            try:
                deq.remove(int(value))
            except ValueError:
                pass operation == "deleteFirst" operation "deleteFirst" deq.popleft() deq.popleft deq popleft elif operation == "deleteLast":
        deq.pop()
    
     operation == "deleteLast" operation "deleteLast" deq.pop() deq.pop deq pop command, value = operation.split() command operation.split() operation.split operation split value if command == "insert":
            deq.appendleft(int(value))
        elif command == "delete":
            try:
                deq.remove(int(value))
            except ValueError:
                pass command == "insert" command "insert" deq.appendleft(int(value)) deq.appendleft deq appendleft int(value) int value elif command == "delete":
            try:
                deq.remove(int(value))
            except ValueError:
                pass command == "delete" command "delete" try:
                deq.remove(int(value))
            except ValueError:
                pass except ValueError:
                pass deq.remove(int(value)) deq.remove deq remove int(value) int value print(*deq) print *deq deq value = operation.split() operation.split() value command, value = operation.split() operation.split() command deq = deque() deque() deq operation = input() input() operation n = int(input()) int(input()) n
from collections import deque


deq = deque()
n = int(input())
for _ in range(n):
    operation = input()
    if operation == "deleteFirst":
        deq.popleft()
    elif operation == "deleteLast":
        deq.pop()
    
    else:
        command, value = operation.split()
        if command == "insert":
            deq.appendleft(int(value))
        elif command == "delete":
            try:
                deq.remove(int(value))
            except ValueError:
                pass

print(*deq)

