from collections import deque

n = int(eval(input()))

li = deque()

for i in range(n):

    command = input().split()

    if command[0] == 'insert':

        li.appendleft(command[1])

    elif command[0] == 'delete':

        try:

            li.remove(command[1])

        except ValueError:

                pass

    elif command[0] == 'deleteFirst':

        li.popleft()

    else:

        li.pop()

print((*li))
from collections import deque

import sys

 

dq = deque()

num = int(sys.stdin.readline())

line = sys.stdin.readlines()

 

for i in range(num):

 

    order = line[i].split()

 

    if order[0] == 'insert':

        dq.appendleft(order[1])

    elif order[0] == 'deleteFirst':

        dq.popleft()

    elif order[0] == 'deleteLast':

        dq.pop()

    else:

        if order[1] in dq:

            dq.remove(order[1])

 

print((' '.join(dq)))
from collections import deque

n = int(eval(input()))
li = deque()
for i in range(n):
    command = input().split()
    if command[0] == "insert":
        li.appendleft(command[1])
    elif command[0] == "delete":
        try:
            li.remove(command[1])
        except ValueError:
            pass
    elif command[0] == "deleteFirst":
        li.popleft()
    else:
        li.pop()
print((*li))

from collections import deque
import sys

dq = deque()
num = int(sys.stdin.readline())
line = sys.stdin.readlines()
for i in range(num):
    order = line[i].split()
    if order[0] == "insert":
        dq.appendleft(order[1])
    elif order[0] == "deleteFirst":
        dq.popleft()
    elif order[0] == "deleteLast":
        dq.pop()
    else:
        if order[1] in dq:
            dq.remove(order[1])
print((" ".join(dq)))

+import sys -n = int(eval(input())) -li = deque() -for i in range(n): -    command = input().split() -    if command[0] == "insert": -        li.appendleft(command[1]) -    elif command[0] == "delete": -        try: -            li.remove(command[1]) -        except ValueError: -            pass -    elif command[0] == "deleteFirst": -        li.popleft() +dq = deque() +num = int(sys.stdin.readline()) +line = sys.stdin.readlines() +for i in range(num): +    order = line[i].split() +    if order[0] == "insert": +        dq.appendleft(order[1]) +    elif order[0] == "deleteFirst": +        dq.popleft() +    elif order[0] == "deleteLast": +        dq.pop() -        li.pop() -print((*li)) +        if order[1] in dq: +            dq.remove(order[1]) +print((" ".join(dq)))