# ALDS1_3_C: Doubly Linked List
# collections.deque
# https://docs.python.org/3.8/library/collections.html#collections.deque

#n = 7
#A = [('insert', 5), ('insert', 2), ('insert', 3), ('insert', 1), 
#     ('delete', 3), ('insert', 6), ('delete', 5),]
from collections import deque

n = int(input())
mylist = deque()
for i in range(n):
    myinput = input().split()
    if len(myinput) == 1:
        order = myinput[0]
        x = 0
    else:
        order, x = myinput

    #print(order, x)
    if order == 'insert': 
        mylist.appendleft(x)
    elif order == 'delete':
        try:
            mylist.remove(x)
        except:
            pass
    elif order == 'deleteFirst':
        #mylist.remove(mylist[0])
        mylist.popleft()
    elif order == 'deleteLast':
        mylist.pop()
    #print(mylist)
print(" ".join(map(str, mylist))) from collections import deque n = int(input()) n int(input()) int input() input mylist = deque() mylist deque() deque for i in range(n):
    myinput = input().split()
    if len(myinput) == 1:
        order = myinput[0]
        x = 0
    else:
        order, x = myinput

    #print(order, x)
    if order == 'insert': 
        mylist.appendleft(x)
    elif order == 'delete':
        try:
            mylist.remove(x)
        except:
            pass
    elif order == 'deleteFirst':
        #mylist.remove(mylist[0])
        mylist.popleft()
    elif order == 'deleteLast':
        mylist.pop()
    #print(mylist) i range(n) range n myinput = input().split() myinput input().split() ().split () input split if len(myinput) == 1:
        order = myinput[0]
        x = 0
    else:
        order, x = myinput

    #print(order, x)
     len(myinput) == 1 len(myinput) len myinput 1 order = myinput[0] order myinput[0] myinput 0 x = 0 x 0 order, x = myinput order myinput x if order == 'insert': 
        mylist.appendleft(x)
    elif order == 'delete':
        try:
            mylist.remove(x)
        except:
            pass
    elif order == 'deleteFirst':
        #mylist.remove(mylist[0])
        mylist.popleft()
    elif order == 'deleteLast':
        mylist.pop()
    #print(mylist) order == 'insert' order 'insert' mylist.appendleft(x) mylist.appendleft mylist appendleft x elif order == 'delete':
        try:
            mylist.remove(x)
        except:
            pass
     order == 'delete' order 'delete' try:
            mylist.remove(x)
        except:
            pass
     except:
            pass
     mylist.remove(x) mylist.remove mylist remove x elif order == 'deleteFirst':
        #mylist.remove(mylist[0])
        mylist.popleft()
     order == 'deleteFirst' order 'deleteFirst' mylist.popleft() mylist.popleft mylist popleft elif order == 'deleteLast':
        mylist.pop()
    #print(mylist) order == 'deleteLast' order 'deleteLast' mylist.pop() mylist.pop mylist pop print(" ".join(map(str, mylist))) print " ".join(map(str, mylist)) " ".join " " join map(str, mylist) map str mylist myinput = input().split() input().split() myinput x = 0 0 x n = int(input()) int(input()) n order, x = myinput myinput order order = myinput[0] myinput[0] order mylist = deque() deque() mylist x = myinput myinput x
# ALDS1_3_C: Doubly Linked List
# collections.deque
# https://docs.python.org/3.8/library/collections.html#collections.deque

#n = 7
#A = [('insert', 5), ('insert', 2), ('insert', 3), ('insert', 1), 
#     ('delete', 3), ('insert', 6), ('delete', 5),]
from collections import deque

n = int(input())
mylist = deque()
for i in range(n):
    myinput = input().split()
    if len(myinput) == 1:
        order = myinput[0]
        x = 0
    else:
        order, x = myinput

    #print(order, x)
    if order == 'insert': 
        mylist.appendleft(x)
    elif order == 'delete':
        try:
            mylist.remove(x)
        except:
            pass
    elif order == 'deleteFirst':
        #mylist.remove(mylist[0])
        mylist.popleft()
    elif order == 'deleteLast':
        mylist.pop()
    #print(mylist)
print(" ".join(map(str, mylist)))
