from collections import deque
n = int(input())
deq = deque([])
for i in range(n):
    A = input().split()
    a = A[0]
    if len(A) == 2:
        b = A[1]
    if a == "insert":
        deq.appendleft(b)
    elif a == "deleteFirst":
        deq.popleft()
    elif a == "deleteLast":
        deq.pop()
    else:
        try:
            deq.remove(b)
        except:
            continue
print(" ".join(list(deq))) from collections import deque n = int(input()) n int(input()) int input() input deq = deque([]) deq deque([]) deque [] for i in range(n):
    A = input().split()
    a = A[0]
    if len(A) == 2:
        b = A[1]
    if a == "insert":
        deq.appendleft(b)
    elif a == "deleteFirst":
        deq.popleft()
    elif a == "deleteLast":
        deq.pop()
    else:
        try:
            deq.remove(b)
        except:
            continue i range(n) range n A = input().split() A input().split() ().split () input split a = A[0] a A[0] A 0 if len(A) == 2:
        b = A[1]
     len(A) == 2 len(A) len A 2 b = A[1] b A[1] A 1 if a == "insert":
        deq.appendleft(b)
    elif a == "deleteFirst":
        deq.popleft()
    elif a == "deleteLast":
        deq.pop()
    else:
        try:
            deq.remove(b)
        except:
            continue a == "insert" a "insert" deq.appendleft(b) deq.appendleft deq appendleft b elif a == "deleteFirst":
        deq.popleft()
     a == "deleteFirst" a "deleteFirst" deq.popleft() deq.popleft deq popleft elif a == "deleteLast":
        deq.pop()
     a == "deleteLast" a "deleteLast" deq.pop() deq.pop deq pop try:
            deq.remove(b)
        except:
            continue except:
            continue continue deq.remove(b) deq.remove deq remove b print(" ".join(list(deq))) print " ".join(list(deq)) " ".join " " join list(deq) list deq n = int(input()) int(input()) n A = input().split() input().split() A a = A[0] A[0] a deq = deque([]) deque([]) deq b = A[1] A[1] b
from collections import deque
n = int(input())
deq = deque([])
for i in range(n):
    A = input().split()
    a = A[0]
    if len(A) == 2:
        b = A[1]
    if a == "insert":
        deq.appendleft(b)
    elif a == "deleteFirst":
        deq.popleft()
    elif a == "deleteLast":
        deq.pop()
    else:
        try:
            deq.remove(b)
        except:
            continue
print(" ".join(list(deq)))
