### BUGGY CODE ###

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

class DLL:
    def __init__(self):
        self.head = Node(None)
        self.head.next = self.head
        self.head.prev = self.head
        self.size = 0
    def insert(self,x):
        n = Node(x)
        temp = self.head.next
        self.head.next.prev = n
        self.head.next = n
        n.next = temp
        n.prev = self.head
        self.size += 1
    def delete(self,x):
        if self.size <= 0:
            print 'underflow'
            exit()
        n = self.head.next
        while n != self.head:
            if n.v == x:
                break
            n = n.next
        if n != self.head:
            n.next.prev = n.prev
            n.prev.next = n.next
            self.size -= 1

    def deleteFirst(self):
        if self.size <= 0:
            print 'underflow'
            exit()
        self.head.next.next.prev = self.head
        self.head.next = self.head.next.next
        self.size -= 1
    def deleteLast(self):
        if self.size <= 0:
            print 'underflow'
            exit()
        self.head.prev.prev.next = self.head
        self.head.prev = self.head.prev.prev
        self.size -= 1


n = int(raw_input())
dll = DLL()
for _ in range(n):
    op = raw_input().split(' ')
    if len(op) == 1:
        if op[0][6] == 'F':
            dll.deleteFirst()
        else:
            dll.deleteLast()
    else:
        if op[0][0] == 'i':
            dll.insert(int(op[1]))
        elif op[0][0] == 'd':
            dll.delete(int(op[1]))

n = dll.head.next
values = []
while n != dll.head:
    values.append(n.v)
    n = n.next

print ' '.join(map(str,values))

### 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()