from collections import deque
 
n=int(input())
command=[0 for i in range(n)]
k=[0 for i in range(n)]
k_queue= deque([])
 
for i in range(n):
    s=input()
    if s=="deleteFirst" or s=="deleteLast":
        command[i],k[i]=s,0
    else:
        command[i],k[i]=s.split()
     
for i in range(n):
    if command[i]=="insert":
        k_queue.appendleft(k[i])
    elif command[i]=="deleteFirst":
        k_queue.popleft()
    elif command[i]=="deleteLast":
        k_queue.pop()
    else:
        try: k_queue.remove(k[i])
        except ValueError: y=0
print( " ".join(map(str, k_queue))) from collections import deque n=int(input()) n int(input()) int input() input 0 for i in range(n) for i in range(n) i range(n) range n for i in range(n) 0 command=[0 for i in range(n)] command [0 for i in range(n)] 0 for i in range(n) for i in range(n) i range(n) range n for i in range(n) 0 k=[0 for i in range(n)] k [0 for i in range(n)] k_queue= deque([]) k_queue deque([]) deque [] for i in range(n):
    s=input()
    if s=="deleteFirst" or s=="deleteLast":
        command[i],k[i]=s,0
    else:
        command[i],k[i]=s.split()
      i range(n) range n s=input() s input() input if s=="deleteFirst" or s=="deleteLast":
        command[i],k[i]=s,0
    else:
        command[i],k[i]=s.split()
      s=="deleteFirst" or s=="deleteLast" s=="deleteFirst" s "deleteFirst" s=="deleteLast" s "deleteLast" command[i],k[i]=s,0 command[i] command i s k[i] k i 0 command[i],k[i]=s.split() command[i] command i s.split() s.split s split k[i] k i for i in range(n):
    if command[i]=="insert":
        k_queue.appendleft(k[i])
    elif command[i]=="deleteFirst":
        k_queue.popleft()
    elif command[i]=="deleteLast":
        k_queue.pop()
    else:
        try: k_queue.remove(k[i])
        except ValueError: y=0 i range(n) range n if command[i]=="insert":
        k_queue.appendleft(k[i])
    elif command[i]=="deleteFirst":
        k_queue.popleft()
    elif command[i]=="deleteLast":
        k_queue.pop()
    else:
        try: k_queue.remove(k[i])
        except ValueError: y=0 command[i]=="insert" command[i] command i "insert" k_queue.appendleft(k[i]) k_queue.appendleft k_queue appendleft k[i] k i elif command[i]=="deleteFirst":
        k_queue.popleft()
     command[i]=="deleteFirst" command[i] command i "deleteFirst" k_queue.popleft() k_queue.popleft k_queue popleft elif command[i]=="deleteLast":
        k_queue.pop()
     command[i]=="deleteLast" command[i] command i "deleteLast" k_queue.pop() k_queue.pop k_queue pop try: k_queue.remove(k[i])
        except ValueError: y=0 except ValueEr print( " ".join(map(str, k_queue))) print " ".join(map(str, k_queue)) " ".join " " join map(str, k_queue) map str k_queue n=int(input()) int(input()) n k_queue= deque([]) deque([]) k_queue s=input() input() s command=[0 for i in range(n)] [0 for i in range(n)] command k=[0 for i in range(n)] [0 for i in range(n)] k
from collections import deque
 
n=int(input())
command=[0 for i in range(n)]
k=[0 for i in range(n)]
k_queue= deque([])
 
for i in range(n):
    s=input()
    if s=="deleteFirst" or s=="deleteLast":
        command[i],k[i]=s,0
    else:
        command[i],k[i]=s.split()
     
for i in range(n):
    if command[i]=="insert":
        k_queue.appendleft(k[i])
    elif command[i]=="deleteFirst":
        k_queue.popleft()
    elif command[i]=="deleteLast":
        k_queue.pop()
    else:
        try: k_queue.remove(k[i])
        except ValueError: y=0
print( " ".join(map(str, k_queue)))
