# coding: utf-8
# Here your code !
import collections
s=int(input())
deq =collections.deque()

for i in range(s):
    n=input().split()
    if n[0]=="insert":
        deq.appendleft(n[1])
    elif n[0]=="delete":
        try:
            deq.remove(n[1])
        except ValueError:
            pass
    elif n[0]=="deleteFirst":
        deq.popleft()
    elif n[0]=="deleteLast":
        deq.pop()
        
print(" ".join(list(deq))) import collections collections s=int(input()) s int(input()) int input() input deq =collections.deque() deq collections.deque() collections.deque collections deque for i in range(s):
    n=input().split()
    if n[0]=="insert":
        deq.appendleft(n[1])
    elif n[0]=="delete":
        try:
            deq.remove(n[1])
        except ValueError:
            pass
    elif n[0]=="deleteFirst":
        deq.popleft()
    elif n[0]=="deleteLast":
        deq.pop()
         i range(s) range s n=input().split() n input().split() ().split () input split if n[0]=="insert":
        deq.appendleft(n[1])
    elif n[0]=="delete":
        try:
            deq.remove(n[1])
        except ValueError:
            pass
    elif n[0]=="deleteFirst":
        deq.popleft()
    elif n[0]=="deleteLast":
        deq.pop()
         n[0]=="insert" n[0] n 0 "insert" deq.appendleft(n[1]) deq.appendleft deq appendleft n[1] n 1 elif n[0]=="delete":
        try:
            deq.remove(n[1])
        except ValueError:
            pass
     n[0]=="delete" n[0] n 0 "delete" try:
            deq.remove(n[1])
        except ValueError:
            pass
     except ValueError:
            pass
     deq.remove(n[1]) deq.remove deq remove n[1] n 1 elif n[0]=="deleteFirst":
        deq.popleft()
     n[0]=="deleteFirst" n[0] n 0 "deleteFirst" deq.popleft() deq.popleft deq popleft elif n[0]=="deleteLast":
        deq.pop()
         n[0]=="deleteLast" n[0] n 0 "deleteLast" deq.pop() deq.pop deq pop print(" ".join(list(deq))) print " ".join(list(deq)) " ".join " " join list(deq) list deq deq =collections.deque() collections.deque() deq s=int(input()) int(input()) s n=input().split() input().split() n
# coding: utf-8
# Here your code !
import collections
s=int(input())
deq =collections.deque()

for i in range(s):
    n=input().split()
    if n[0]=="insert":
        deq.appendleft(n[1])
    elif n[0]=="delete":
        try:
            deq.remove(n[1])
        except ValueError:
            pass
    elif n[0]=="deleteFirst":
        deq.popleft()
    elif n[0]=="deleteLast":
        deq.pop()
        
print(" ".join(list(deq)))