from collections import deque

times = int(input())
stack = deque()
for i in range(times):
    op = input().split()
    if op[0] == "insert":
        stack.appendleft(op[1])
    if op[0] == "delete":
        if op[1] in stack:
            stack.remove(op[1])
    if op[0] == "deleteFirst":
        stack.popleft()
    if op[0] == "deleteLast":
        stack.pop()
print(*stack) from collections import deque times = int(input()) times int(input()) int input() input stack = deque() stack deque() deque for i in range(times):
    op = input().split()
    if op[0] == "insert":
        stack.appendleft(op[1])
    if op[0] == "delete":
        if op[1] in stack:
            stack.remove(op[1])
    if op[0] == "deleteFirst":
        stack.popleft()
    if op[0] == "deleteLast":
        stack.pop() i range(times) range times op = input().split() op input().split() ().split () input split if op[0] == "insert":
        stack.appendleft(op[1])
     op[0] == "insert" op[0] op 0 "insert" stack.appendleft(op[1]) stack.appendleft stack appendleft op[1] op 1 if op[0] == "delete":
        if op[1] in stack:
            stack.remove(op[1])
     op[0] == "delete" op[0] op 0 "delete" if op[1] in stack:
            stack.remove(op[1])
     op[1] in stack op[1] op 1 stack stack.remove(op[1]) stack.remove stack remove op[1] op 1 if op[0] == "deleteFirst":
        stack.popleft()
     op[0] == "deleteFirst" op[0] op 0 "deleteFirst" stack.popleft() stack.popleft stack popleft if op[0] == "deleteLast":
        stack.pop() op[0] == "deleteLast" op[0] op 0 "deleteLast" stack.pop() stack.pop stack pop print(*stack) print *stack stack times = int(input()) int(input()) times op = input().split() input().split() op stack = deque() deque() stack
from collections import deque

times = int(input())
stack = deque()
for i in range(times):
    op = input().split()
    if op[0] == "insert":
        stack.appendleft(op[1])
    if op[0] == "delete":
        if op[1] in stack:
            stack.remove(op[1])
    if op[0] == "deleteFirst":
        stack.popleft()
    if op[0] == "deleteLast":
        stack.pop()
print(*stack)
