from sys import stdin

class Sentinel():
    def __init__(self):
        self.value = None
        self.next = None
        self.prev = None

class Node():
    def __init__(self, value):
        self.value = value
        self.next = None
        self.prev = None

def Insert(key):
    node = Node(key)
    node.next = sent.next
    sent.next.prev = node
    sent.next = node
    node.prev = sent

def Search(key):
    p = sent.next
    while p.value != None:
        if p.value == key:
            return p
        else:
            p = p.next
    return False

def Delete(key):
    p = Search(key)
    if p != False:
        p.prev.next = p.next
        p.next.prev = p.prev

def DeleteF():
    p = sent.next
    p.prev.next = p.next
    p.next.prev = p.prev

def DeleteL():
    p = sent.prev
    p.prev.next = p.next
    p.next.prev = p.prev

sent = Sentinel()
sent.next = sent
sent.prev = sent

n = int(input())
for i in range(n):
    L = stdin.readline().split()
    if L[0] == 'insert':
        Insert(int(L[1]))
    elif L[0] == 'delete':
        Delete(int(L[1]))
    elif  L[0] == 'deleteFirst':
        DeleteF()
    elif  L[0] == 'deleteLast':
        DeleteL()

p = sent.next
tl = []
while True:
    tl.append(p.value)
    p = p.next
    if p.value == None:
        break
print(' '.join(str(x) for x in tl)) from sys import stdin class Sentinel():
    def __init__(self):
        self.value = None
        self.next = None
        self.prev = None Sentinel def __init__(self):
        self.value = None
        self.next = None
        self.prev = None __init__ self.value = None self.value self value None self.next = None self.next self next None self.prev = None self.prev self prev None self self class Node():
    def __init__(self, value):
        self.value = value
        self.next = None
        self.prev = None Node def __init__(self, value):
        self.value = value
        self.next = None
        self.prev = None __init__ self.value = value self.value self value value self.next = None self.next self next None self.prev = None self.prev self prev None self self value value def Insert(key):
    node = Node(key)
    node.next = sent.next
    sent.next.prev = node
    sent.next = node
    node.prev = sent Insert node = Node(key) node Node(key) Node key node.next = sent.next node.next node next sent.next sent next sent.next.prev = node sent.next.prev sent.next sent next prev node sent.next = node sent.next sent next node node.prev = sent node.prev node prev sent key key def Search(key):
    p = sent.next
    while p.value != None:
        if p.value == key:
            return p
        else:
            p = p.next
    return False Search p = sent.next p sent.next sent next while p.value != None:
        if p.value == key:
            return p
        else:
            p = p.next
     p.value != None p.value p value None if p.value == key:
            return p
        else:
            p = p.next
     p.value == key p.value p value key return p p p = p.next p p.next p next return False False key key def Delete(key):
    p = Search(key)
    if p != False:
        p.prev.next = p.next
        p.next.prev = p.prev Delete p = Search(key) p Search(key) Search key if p != False:
        p.prev.next = p.next
        p.next.prev = p.prev p != False p False p.prev.next = p.next p.prev.next p.prev p prev next p.next p next p.next.prev = p.prev p.next.prev p.next p next prev p.prev p prev key key def DeleteF():
    p = sent.next
    p.prev.next = p.next
    p.next.prev = p.prev DeleteF p = sent.next p sent.next sent next p.prev.next = p.next p.prev.next p.prev p prev next p.next p next p.next.prev = p.prev p.next.prev p.next p next prev p.prev p prev def DeleteL():
    p = sent.prev
    p.prev.next = p.next
    p.next.prev = p.prev DeleteL p = sent.prev p sent.prev sent prev p.prev.next = p.next p.prev.next p.prev p prev next p.next p next p.next.prev = p.prev p.next.prev p.next p next prev p.prev p prev sent = Sentinel() sent Sentinel() Sentinel sent.next = sent sent.next sent next sent sent.prev = sent sent.prev sent prev sent n = int(input()) n int(input()) int input() input for i in range(n):
    L = stdin.readline().split()
    if L[0] == 'insert':
        Insert(int(L[1]))
    elif L[0] == 'delete':
        Delete(int(L[1]))
    elif  L[0] == 'deleteFirst':
        DeleteF()
    elif  L[0] == 'deleteLast':
        DeleteL() i range(n) range n L = stdin.readline().split() L stdin.readline().split() stdin.readline().split stdin.readline() stdin.readline stdin readline split if L[0] == 'insert':
        Insert(int(L[1]))
    elif L[0] == 'delete':
        Delete(int(L[1]))
    elif  L[0] == 'deleteFirst':
        DeleteF()
    elif  L[0] == 'deleteLast':
        DeleteL() L[0] == 'insert' L[0] L 0 'insert' Insert(int(L[1])) Insert int(L[1]) int L[1] L 1 elif L[0] == 'delete':
        Delete(int(L[1]))
     L[0] == 'delete' L[0] L 0 'delete' Delete(int(L[1])) Delete int(L[1]) int L[1] L 1 elif  L[0] == 'deleteFirst':
        DeleteF()
     L[0] == 'deleteFirst' L[0] L 0 'deleteFirst' DeleteF() DeleteF elif  L[0] == 'deleteLast':
        DeleteL() L[0] == 'deleteLast' L[0] L 0 'deleteLast' DeleteL() DeleteL p = sent.next p sent.next sent next tl = [] tl [] while True:
    tl.append(p.value)
    p = p.next
    if p.value == None:
        break True tl.append(p.value) tl.append tl append p.value p value p = p.next p p.next p next if p.value == None:
        break p.value == None p.value p value None break print(' '.join(str(x) for x in tl)) print ' '.join(str(x) for x in tl) ' '.join ' ' join str(x) str x sent = Sentinel() Sentinel() sent n = int(input()) int(input()) n def Insert(key):
    node = Node(key)
    node.next = sent.next
    sent.next.prev = node
    sent.next = node
    node.prev = sent def Insert(key):
    node = Node(key)
    node.next = sent.next
    sent.next.prev = node
    sent.next = node
    node.prev = sent Insert tl = [] [] tl class Sentinel():
    def __init__(self):
        self.value = None
        self.next = None
        self.prev = None class Sentinel():
    def __init__(self):
        self.value = None
        self.next = None
        self.prev = None Sentinel p = p.next p.next p def DeleteF():
    p = sent.next
    p.prev.next = p.next
    p.next.prev = p.prev def DeleteF():
    p = sent.next
    p.prev.next = p.next
    p.next.prev = p.prev DeleteF L = stdin.readline().split() stdin.readline().split() L def DeleteL():
    p = sent.prev
    p.prev.next = p.next
    p.next.prev = p.prev def DeleteL():
    p = sent.prev
    p.prev.next = p.next
    p.next.prev = p.prev DeleteL class Node():
    def __init__(self, value):
        self.value = value
        self.next = None
        self.prev = None class Node():
    def __init__(self, value):
        self.value = value
        self.next = None
        self.prev = None Node def Delete(key):
    p = Search(key)
    if p != False:
        p.prev.next = p.next
        p.next.prev = p.prev def Delete(key):
    p = Search(key)
    if p != False:
        p.prev.next = p.next
        p.next.prev = p.prev Delete p = sent.next sent.next p def Search(key):
    p = sent.next
    while p.value != None:
        if p.value == key:
            return p
        else:
            p = p.next
    return False def Search(key):
    p = sent.next
    while p.value != None:
        if p.value == key:
            return p
        else:
            p = p.next
    return False Search
from sys import stdin

class Sentinel():
    def __init__(self):
        self.value = None
        self.next = None
        self.prev = None

class Node():
    def __init__(self, value):
        self.value = value
        self.next = None
        self.prev = None

def Insert(key):
    node = Node(key)
    node.next = sent.next
    sent.next.prev = node
    sent.next = node
    node.prev = sent

def Search(key):
    p = sent.next
    while p.value != None:
        if p.value == key:
            return p
        else:
            p = p.next
    return False

def Delete(key):
    p = Search(key)
    if p != False:
        p.prev.next = p.next
        p.next.prev = p.prev

def DeleteF():
    p = sent.next
    p.prev.next = p.next
    p.next.prev = p.prev

def DeleteL():
    p = sent.prev
    p.prev.next = p.next
    p.next.prev = p.prev

sent = Sentinel()
sent.next = sent
sent.prev = sent

n = int(input())
for i in range(n):
    L = stdin.readline().split()
    if L[0] == 'insert':
        Insert(int(L[1]))
    elif L[0] == 'delete':
        Delete(int(L[1]))
    elif  L[0] == 'deleteFirst':
        DeleteF()
    elif  L[0] == 'deleteLast':
        DeleteL()

p = sent.next
tl = []
while True:
    tl.append(p.value)
    p = p.next
    if p.value == None:
        break
print(' '.join(str(x) for x in tl))
