from collections import deque
def insert(x,a):
    a.appendleft(x)
def delete(x,a):
    if x in a:
        a.remove(x)
    else:
        return
def deletefirst(a):
    a.popleft()
def deletelast(a):
    a.pop()
n=input()
a=deque()
for i in xrange(n):
    s=raw_input().split()
    if s[0]=="insert":
        insert(s[1],a)
    elif s[0]=="delete":
        delete(s[1],a)
    elif s[0]=="deleteFirst":
        deletefirst(a)
    else:
        deletelast(a)
print(" ".join(a)) from collections import deque def insert(x,a):
    a.appendleft(x) insert a.appendleft(x) a.appendleft a appendleft x x x a a def delete(x,a):
    if x in a:
        a.remove(x)
    else:
        return delete if x in a:
        a.remove(x)
    else:
        return x in a x a a.remove(x) a.remove a remove x return x x a a def deletefirst(a):
    a.popleft() deletefirst a.popleft() a.popleft a popleft a a def deletelast(a):
    a.pop() deletelast a.pop() a.pop a pop a a n=input() n input() input a=deque() a deque() deque for i in xrange(n):
    s=raw_input().split()
    if s[0]=="insert":
        insert(s[1],a)
    elif s[0]=="delete":
        delete(s[1],a)
    elif s[0]=="deleteFirst":
        deletefirst(a)
    else:
        deletelast(a) i xrange(n) xrange n s=raw_input().split() s raw_input().split() ().split () raw_input split if s[0]=="insert":
        insert(s[1],a)
    elif s[0]=="delete":
        delete(s[1],a)
    elif s[0]=="deleteFirst":
        deletefirst(a)
    else:
        deletelast(a) s[0]=="insert" s[0] s 0 "insert" insert(s[1],a) insert s[1] s 1 a elif s[0]=="delete":
        delete(s[1],a)
     s[0]=="delete" s[0] s 0 "delete" delete(s[1],a) delete s[1] s 1 a elif s[0]=="deleteFirst":
        deletefirst(a)
     s[0]=="deleteFirst" s[0] s 0 "deleteFirst" deletefirst(a) deletefirst a deletelast(a) deletelast a print(" ".join(a)) print " ".join(a) " ".join " " join a def deletelast(a):
    a.pop() def deletelast(a):
    a.pop() deletelast a=deque() deque() a def delete(x,a):
    if x in a:
        a.remove(x)
    else:
        return def delete(x,a):
    if x in a:
        a.remove(x)
    else:
        return delete n=input() input() n def deletefirst(a):
    a.popleft() def deletefirst(a):
    a.popleft() deletefirst def insert(x,a):
    a.appendleft(x) def insert(x,a):
    a.appendleft(x) insert s=raw_input().split() raw_input().split() s
from collections import deque
def insert(x,a):
    a.appendleft(x)
def delete(x,a):
    if x in a:
        a.remove(x)
    else:
        return
def deletefirst(a):
    a.popleft()
def deletelast(a):
    a.pop()
n=input()
a=deque()
for i in xrange(n):
    s=raw_input().split()
    if s[0]=="insert":
        insert(s[1],a)
    elif s[0]=="delete":
        delete(s[1],a)
    elif s[0]=="deleteFirst":
        deletefirst(a)
    else:
        deletelast(a)
print(" ".join(a))