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

