from collections import deque
n =  int(input())

mylist = deque()


for i in range(n):
    a = input()
    if a == "deleteFirst":
        mylist.popleft()
    elif a == "deleteLast":
        mylist.pop()
    else:
        a,key = a.split()
        if a == "insert":
            mylist.appendleft(key)
        else:
            try:
                mylist.remove(key)
            except:
                pass

print(' '.join(mylist))
 from collections import deque n =  int(input()) n int(input()) int input() input mylist = deque() mylist deque() deque for i in range(n):
    a = input()
    if a == "deleteFirst":
        mylist.popleft()
    elif a == "deleteLast":
        mylist.pop()
    else:
        a,key = a.split()
        if a == "insert":
            mylist.appendleft(key)
        else:
            try:
                mylist.remove(key)
            except:
                pass i range(n) range n a = input() a input() input if a == "deleteFirst":
        mylist.popleft()
    elif a == "deleteLast":
        mylist.pop()
    else:
        a,key = a.split()
        if a == "insert":
            mylist.appendleft(key)
        else:
            try:
                mylist.remove(key)
            except:
                pass a == "deleteFirst" a "deleteFirst" mylist.popleft() mylist.popleft mylist popleft elif a == "deleteLast":
        mylist.pop()
     a == "deleteLast" a "deleteLast" mylist.pop() mylist.pop mylist pop a,key = a.split() a a.split() a.split a split key if a == "insert":
            mylist.appendleft(key)
        else:
            try:
                mylist.remove(key)
            except:
                pass a == "insert" a "insert" mylist.appendleft(key) mylist.appendleft mylist appendleft key try:
                mylist.remove(key)
            except:
                pass except:
                pass mylist.remove(key) mylist.remove mylist remove key print(' '.join(mylist)) print ' '.join(mylist) ' '.join ' ' join mylist a,key = a.split() a.split() a key = a.split() a.split() key n =  int(input()) int(input()) n mylist = deque() deque() mylist a = input() input() a
from collections import deque
n =  int(input())

mylist = deque()


for i in range(n):
    a = input()
    if a == "deleteFirst":
        mylist.popleft()
    elif a == "deleteLast":
        mylist.pop()
    else:
        a,key = a.split()
        if a == "insert":
            mylist.appendleft(key)
        else:
            try:
                mylist.remove(key)
            except:
                pass

print(' '.join(mylist))

