# -*- coding: utf-8 -*-



import sys

import os

from collections import deque





N = int(eval(input()))

q = deque()



for i in range(N):

    lst = input().split()

    command = lst[0]

    if command == 'insert':

        v = int(lst[1])

        q.appendleft(v)

    elif command == 'delete':

        v = int(lst[1])

        try:

            q.remove(v)

        except Exception:

            pass

    elif command == 'deleteFirst':

        q.popleft()

    elif command == 'deleteLast':

        q.pop()



print((*q))
import sys

from collections import deque

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

lines = sys.stdin.readlines()

 

Q = deque()

for i in range(n):

    command = lines[i].split()

    if command[0] == "insert":

        Q.appendleft(command[1])

    elif command[0] == "deleteFirst":

        Q.popleft()

    elif command[0] == "deleteLast":

        Q.pop()

    elif command[0] == "delete":

        try:

            Q.remove(command[1])

        except:

            pass

print((" ".join(Q)))



# 0.158sec??§?????????????¢????
# -*- coding: utf-8 -*-
import sys
import os
from collections import deque

N = int(eval(input()))
q = deque()
for i in range(N):
    lst = input().split()
    command = lst[0]
    if command == "insert":
        v = int(lst[1])
        q.appendleft(v)
    elif command == "delete":
        v = int(lst[1])
        try:
            q.remove(v)
        except Exception:
            pass
    elif command == "deleteFirst":
        q.popleft()
    elif command == "deleteLast":
        q.pop()
print((*q))

import sys
from collections import deque

n = int(sys.stdin.readline())
lines = sys.stdin.readlines()
Q = deque()
for i in range(n):
    command = lines[i].split()
    if command[0] == "insert":
        Q.appendleft(command[1])
    elif command[0] == "deleteFirst":
        Q.popleft()
    elif command[0] == "deleteLast":
        Q.pop()
    elif command[0] == "delete":
        try:
            Q.remove(command[1])
        except:
            pass
print((" ".join(Q)))
# 0.158sec??§?????????????¢????

-# -*- coding: utf-8 -*- -import os -N = int(eval(input())) -q = deque() -for i in range(N): -    lst = input().split() -    command = lst[0] -    if command == "insert": -        v = int(lst[1]) -        q.appendleft(v) -    elif command == "delete": -        v = int(lst[1]) +n = int(sys.stdin.readline()) +lines = sys.stdin.readlines() +Q = deque() +for i in range(n): +    command = lines[i].split() +    if command[0] == "insert": +        Q.appendleft(command[1]) +    elif command[0] == "deleteFirst": +        Q.popleft() +    elif command[0] == "deleteLast": +        Q.pop() +    elif command[0] == "delete": -            q.remove(v) -        except Exception: +            Q.remove(command[1]) +        except: -    elif command == "deleteFirst": -        q.popleft() -    elif command == "deleteLast": -        q.pop() -print((*q)) +print((" ".join(Q))) +# 0.158sec??§?????????????¢????