### BUGGY CODE ###

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

class DoublyLinkedList:
    def __init__(self):
        self.nil = Node(None)
        self.nil.next = self.nil
        self.nil.prev = self.nil

    def __str__(self):
        ret = ''
        n = self.nil.next
        while True:
            if n.data == None:
                break
            else:
                ret += str(n.data) + ' '
                n = n.next
        return ret[:-1]


    def insert(self,v):
        n = Node(v)
        if self.nil.next.data == None:
            self.nil.next = n
            self.nil.prev = n
            n.next = self.nil
            n.prev = self.nil
        else:
            n.next = self.nil.next
            n.prev = self.nil
            n.next.prev = n
            self.nil.next = n

    def delete(self,v):
        n = self.nil.next
        while True:
            if n.data == None:
                break
            else:
                if n.data == v:
                    if n.next.data == None:
                        self.nil.prev = n.prev
                    else:
                        n.next.prev = n.prev
                    if n.prev == None:
                        self.nil.next = n.next
                    else:
                        n.prev.next = n.next
                    break
                n = n.next

    def deleteFirst(self):
        if self.nil.next.data != None:
            self.nil.next = self.nil.next.next
            if self.nil.next.data != None:
                self.nil.next.prev = self.nil
            else:
                self.nil.prev = self.nil
        else:
            raise


    def deleteLast(self):
        if self.nil.prev.data != None:
            self.nil.prev = self.nil.prev.prev
            if self.nil.prev.data != None:
                self.nil.prev.next = self.nil
            else:
                self.nil.next = self.nil
        else:
            raise

n = int(raw_input())

l = DoublyLinkedList()
for i in range(n):
    c = raw_input()
    if c == "deleteFirst":
        l.deleteFirst()
    elif c == "deleteLast":
        l.deleteLast()
    else:
        op,val = c.split(' ')
        val = int(val)
        if op == "insert":
            l.insert(val)
        elif op == "delete":
            l.delete(val)

print l

### FIXED CODE ###

class DoublyLinkedList:
    def __init__(self):
        self.nil = self.make_node(None)
        self.nil['next'] = self.nil
        self.nil['prev'] = self.nil

    def make_node(self,v):
        return {'key':v, 'next':None, 'prev':None}

    def dump(self):
        n = self.nil['next']
        while True:
            if n['key'] == None:
                break
            else:
                print str(n['key']),
                n = n['next']
        print


    def insert(self,v):
        n = self.make_node(v)
        n['next'] = self.nil['next']
        self.nil['next']['prev'] = n
        n['prev'] = self.nil
        self.nil['next'] = n

    def delete(self,v):
        self.delete_node(self.list_search(v))

    def delete_node(self,n):
        if n['key'] == None: return
        n['next']['prev'] = n['prev']
        n['prev']['next'] = n['next']

    def list_search(self,v):
        cur = self.nil['next']
        while (cur['key'] != None) and (cur['key'] != v):
            cur = cur['next']
        return cur

    def deleteFirst(self):
        self.delete_node(self.nil['next'])

    def deleteLast(self):
        self.delete_node(self.nil['prev'])

n = int(raw_input())
commands = []
for i in range(n):
    commands.append(raw_input())

l = DoublyLinkedList()
for c in commands:
    a = c[6]
    if a == "F":
        l.deleteFirst()
    elif a == "L":
        l.deleteLast()
    else:
        val = int(c[7:])
        op = c[0]
        if op == "i":
            l.insert(val)
        else:
            l.delete(val)

l.dump()