from _collections import deque



n = int(eval(input()))

data_input = []

dlList = deque()

for i in range(n):

    x = input().split()

    if x[0] == 'insert':

        dlList.appendleft(x[1])

    elif x[0] == 'delete':

        if x[1] in dlList:

            dlList.remove(x[1])

        else :

            pass

    elif x[0] == 'deleteFirst':

        dlList.popleft()

    elif x[0] == 'deleteLast':

        dlList.pop()

    else:

        pass



print((' '.join(dlList)))
import sys

from collections import deque

input_lines = sys.stdin.readlines()



doublyLinkedList = deque()





for x in input_lines[1:]:

    oneLine = x.split()

    if 'insert' in oneLine[0]:

        doublyLinkedList.appendleft((int)(oneLine[1]))

    elif 'delete' == oneLine[0]:

        remove_value = (int)(oneLine[1])

        if remove_value in doublyLinkedList:

            doublyLinkedList.remove(remove_value)

    elif 'deleteFirst'in oneLine[0]:

        doublyLinkedList.popleft()

    elif 'deleteLast' in oneLine[0]:

        doublyLinkedList.pop()



print((*doublyLinkedList))
from _collections import deque

n = int(eval(input()))
data_input = []
dlList = deque()
for i in range(n):
    x = input().split()
    if x[0] == "insert":
        dlList.appendleft(x[1])
    elif x[0] == "delete":
        if x[1] in dlList:
            dlList.remove(x[1])
        else:
            pass
    elif x[0] == "deleteFirst":
        dlList.popleft()
    elif x[0] == "deleteLast":
        dlList.pop()
    else:
        pass
print((" ".join(dlList)))

import sys
from collections import deque

input_lines = sys.stdin.readlines()
doublyLinkedList = deque()
for x in input_lines[1:]:
    oneLine = x.split()
    if "insert" in oneLine[0]:
        doublyLinkedList.appendleft((int)(oneLine[1]))
    elif "delete" == oneLine[0]:
        remove_value = (int)(oneLine[1])
        if remove_value in doublyLinkedList:
            doublyLinkedList.remove(remove_value)
    elif "deleteFirst" in oneLine[0]:
        doublyLinkedList.popleft()
    elif "deleteLast" in oneLine[0]:
        doublyLinkedList.pop()
print((*doublyLinkedList))

-from _collections import deque +import sys +from collections import deque -n = int(eval(input())) -data_input = [] -dlList = deque() -for i in range(n): -    x = input().split() -    if x[0] == "insert": -        dlList.appendleft(x[1]) -    elif x[0] == "delete": -        if x[1] in dlList: -            dlList.remove(x[1]) -        else: -            pass -    elif x[0] == "deleteFirst": -        dlList.popleft() -    elif x[0] == "deleteLast": -        dlList.pop() -    else: -        pass -print((" ".join(dlList))) +input_lines = sys.stdin.readlines() +doublyLinkedList = deque() +for x in input_lines[1:]: +    oneLine = x.split() +    if "insert" in oneLine[0]: +        doublyLinkedList.appendleft((int)(oneLine[1])) +    elif "delete" == oneLine[0]: +        remove_value = (int)(oneLine[1]) +        if remove_value in doublyLinkedList: +            doublyLinkedList.remove(remove_value) +    elif "deleteFirst" in oneLine[0]: +        doublyLinkedList.popleft() +    elif "deleteLast" in oneLine[0]: +        doublyLinkedList.pop() +print((*doublyLinkedList))