from collections import deque
n = int(input())
d = deque()
for i in range(n):
    x = input().split()

    if x[0] == "insert":
        d.appendleft(x[1])
    elif x[0] == "delete":
        if x[1] in d:
            d.remove(x[1])
    elif x[0] == "deleteFirst":
        d.popleft()
    elif x[0] == "deleteLast":
        d.pop()

print(*d)
 from collections import deque n = int(input()) n int(input()) int input() input d = deque() d deque() deque for i in range(n):
    x = input().split()

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

    if x[0] == "insert":
        d.appendleft(x[1])
    elif x[0] == "delete":
        if x[1] in d:
            d.remove(x[1])
    elif x[0] == "deleteFirst":
        d.popleft()
    elif x[0] == "deleteLast":
        d.pop()

print(*d)

