### BUGGY CODE ###

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

class DoublyLinkedList:
    def __init__(self):
        self.head = None
        self.tail = None

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


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

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

    def deleteFirst(self):
        if self.head != None:
            self.head = self.head.next
            if self.head != None:
                self.head.prev = None
            else:
                self.tail = None
        else:
            raise


    def deleteLast(self):
        if self.tail != None:
            self.tail = self.tail.prev
            if self.tail != None:
                self.tail.next = None
            else:
                self.head = None
        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()