from sys import stdin

class DList:
    class Cell:
        def __init__(self, k):
            self.key  = k
            self.prev = None
            self.next = None

    def __init__(self):
        self.head = DList.Cell(None)
        self.last = DList.Cell(None)
        self.head.next = self.last
        self.last.prev = self.head

    def insert(self, x):
        c = DList.Cell(x)
        c.prev = self.head
        c.next = self.head.next
        c.next.prev = c
        self.head.next = c

    def delete(self, x):
        c = self.__find(x)
        if c != None:
            self.__delete(c)

    def __delete(self, c):
        c.prev.next = c.next
        c.next.prev = c.prev

    def __find(self, x):
        c = self.head.next
        while c != None and c.key != x:
            c = c.next
        return c

    def deleteFirst(self):
        self.__delete(self.head.next)
    def deleteLast(self):
        self.__delete(self.last.prev)

    def __iter__(self):
        self.it = self.head.next
        return self
    def __next__(self):
        if self.it == self.last:
            raise StopIteration
        k = self.it.key
        self.it = self.it.next
        return k

dlist = DList()

n = int(stdin.readline())
for i in range(n):
    cmd = stdin.readline()
    if   cmd.startswith('insert'):
        dlist.insert(cmd[7:-1])
    elif cmd.startswith('deleteFirst'):
        dlist.deleteFirst()
    elif cmd.startswith('deleteLast'):
        dlist.deleteLast()
    elif cmd.startswith('delete'):
        dlist.delete(cmd[7:-1])

print(' '.join(dlist))
 from sys import stdin class DList:
    class Cell:
        def __init__(self, k):
            self.key  = k
            self.prev = None
            self.next = None

    def __init__(self):
        self.head = DList.Cell(None)
        self.last = DList.Cell(None)
        self.head.next = self.last
        self.last.prev = self.head

    def insert(self, x):
        c = DList.Cell(x)
        c.prev = self.head
        c.next = self.head.next
        c.next.prev = c
        self.head.next = c

    def delete(self, x):
        c = self.__find(x)
        if c != None:
            self.__delete(c)

    def __delete(self, c):
        c.prev.next = c.next
        c.next.prev = c.prev

    def __find(self, x):
        c = self.head.next
        while c != None and c.key != x:
            c = c.next
        return c

    def deleteFirst(self):
        self.__delete(self.head.next)
    def deleteLast(self):
        self.__delete(self.last.prev)

    def __iter__(self):
        self.it = self.head.next
        return self
    def __next__(self):
        if self.it == self.last:
            raise StopIteration
        k = self.it.key
        self.it = self.it.next
        return k DList class Cell:
        def __init__(self, k):
            self.key  = k
            self.prev = None
            self.next = None

     Cell def __init__(self, k):
            self.key  = k
            self.prev = None
            self.next = None

     __init__ self.key  = k self.key self key k self.prev = None self.prev self prev None self.next = None self.next self next None self self k k def __init__(self):
        self.head = DList.Cell(None)
        self.last = DList.Cell(None)
        self.head.next = self.last
        self.last.prev = self.head

     __init__ self.head = DList.Cell(None) self.head self head DList.Cell(None) DList.Cell DList Cell None self.last = DList.Cell(None) self.last self last DList.Cell(None) DList.Cell DList Cell None self.head.next = self.last self.head.next self.head self head next self.last self last self.last.prev = self.head self.last.prev self.last self last prev self.head self head self self def insert(self, x):
        c = DList.Cell(x)
        c.prev = self.head
        c.next = self.head.next
        c.next.prev = c
        self.head.next = c

     insert c = DList.Cell(x) c DList.Cell(x) DList.Cell DList Cell x c.prev = self.head c.prev c prev self.head self head c.next = self.head.next c.next c next self.head.next self.head self head next c.next.prev = c c.next.prev c.next c next prev c self.head.next = c self.head.next self.head self head next c self self x x def delete(self, x):
        c = self.__find(x)
        if c != None:
            self.__delete(c)

     delete c = self.__find(x) c self.__find(x) self.__find self __find x if c != None:
            self.__delete(c)

     c != None c None self.__delete(c) self.__delete self __delete c self self x x def __delete(self, c):
        c.prev.next = c.next
        c.next.prev = c.prev

     __delete c.prev.next = c.next c.prev.next c.prev c prev next c.next c next c.next.prev = c.prev c.next.prev c.next c next prev c.prev c prev self self c c def __find(self, x):
        c = self.head.next
        while c != None and c.key != x:
            c = c.next
        return c

     __find c = self.head.next c self.head.next self.head self head next while c != None and c.key != x:
            c = c.next
         c != None and c.key != x c != None c None c.key != x c.key c key x c = c.next c c.next c next return c c self self x x def deleteFirst(self):
        self.__delete(self.head.next)
     deleteFirst self.__delete(self.head.next) self.__delete self __delete self.head.next self.head self head next self self def deleteLast(self):
        self.__delete(self.last.prev)

     deleteLast self.__delete(self.last.prev) self.__delete self __delete self.last.prev self.last self last prev self self def __iter__(self):
        self.it = self.head.next
        return self
     __iter__ self.it = self.head.next self.it self it self.head.next self.head self head next return self self self self def __next__(self):
        if self.it == self.last:
            raise StopIteration
        k = self.it.key
        self.it = self.it.next
        return k __next__ if self.it == self.last:
            raise StopIteration
         self.it == self.last self.it self it self.last self last raise StopIteration StopIteration k = self.it.key k self.it.key self.it self it key self.it = self.it.next self.it self it self.it.next self.it self it next return k k self self dlist = DList() dlist DList() DList n = int(stdin.readline()) n int(stdin.readline()) int stdin.readline() stdin.readline stdin readline for i in range(n):
    cmd = stdin.readline()
    if   cmd.startswith('insert'):
        dlist.insert(cmd[7:-1])
    elif cmd.startswith('deleteFirst'):
        dlist.deleteFirst()
    elif cmd.startswith('deleteLast'):
        dlist.deleteLast()
    elif cmd.startswith('delete'):
        dlist.delete(cmd[7:-1]) i range(n) range n cmd = stdin.readline() cmd stdin.readline() stdin.readline stdin readline if   cmd.startswith('insert'):
        dlist.insert(cmd[7:-1])
    elif cmd.startswith('deleteFirst'):
        dlist.deleteFirst()
    elif cmd.startswith('deleteLast'):
        dlist.deleteLast()
    elif cmd.startswith('delete'):
        dlist.delete(cmd[7:-1]) cmd.startswith('insert') cmd.startswith cmd startswith 'insert' dlist.insert(cmd[7:-1]) dlist.insert dlist insert cmd[7:-1] cmd 7:-1 7 -1 elif cmd.startswith('deleteFirst'):
        dlist.deleteFirst()
     cmd.startswith('deleteFirst') cmd.startswith cmd startswith 'deleteFirst' dlist.deleteFirst() dlist.deleteFirst dlist deleteFirst elif cmd.startswith('deleteLast'):
        dlist.deleteLast()
     cmd.startswith('deleteLast') cmd.startswith cmd startswith 'deleteLast' dlist.deleteLast() dlist.deleteLast dlist deleteLast elif cmd.startswith('delete'):
        dlist.delete(cmd[7:-1]) cmd.startswith('delete') cmd.startswith cmd startswith 'delete' dlist.delete(cmd[7:-1]) dlist.delete dlist delete cmd[7:-1] cmd 7:-1 7 -1 print(' '.join(dlist)) print ' '.join(dlist) ' '.join ' ' join dlist class DList:
    class Cell:
        def __init__(self, k):
            self.key  = k
            self.prev = None
            self.next = None

    def __init__(self):
        self.head = DList.Cell(None)
        self.last = DList.Cell(None)
        self.head.next = self.last
        self.last.prev = self.head

    def insert(self, x):
        c = DList.Cell(x)
        c.prev = self.head
        c.next = self.head.next
        c.next.prev = c
        self.head.next = c

    def delete(self, x):
        c = self.__find(x)
        if c != None:
            self.__delete(c)

    def __delete(self, c):
        c.prev.next = c.next
        c.next.prev = c.prev

    def __find(self, x):
        c = self.head.next
        while c != None and c.key != x:
            c = c.next
        return c

    def deleteFirst(self):
        self.__delete(self.head.next)
    def deleteLast(self):
        self.__delete(self.last.prev)

    def __iter__(self):
        self.it = self.head.next
        return self
    def __next__(self):
        if self.it == self.last:
            raise StopIteration
        k = self.it.key
        self.it = self.it.next
        return k class DList:
    class Cell:
        def __init__(self, k):
            self.key  = k
            self.prev = None
            self.next = None

    def __init__(self):
        self.head = DList.Cell(None)
        self.last = DList.Cell(None)
        self.head.next = self.last
        self.last.prev = self.head

    def insert(self, x):
        c = DList.Cell(x)
        c.prev = self.head
        c.next = self.head.next
        c.next.prev = c
        self.head.next = c

    def delete(self, x):
        c = self.__find(x)
        if c != None:
            self.__delete(c)

    def __delete(self, c):
        c.prev.next = c.next
        c.next.prev = c.prev

    def __find(self, x):
        c = self.head.next
        while c != None and c.key != x:
            c = c.next
        return c

    def deleteFirst(self):
        self.__delete(self.head.next)
    def deleteLast(self):
        self.__delete(self.last.prev)

    def __iter__(self):
        self.it = self.head.next
        return self
    def __next__(self):
        if self.it == self.last:
            raise StopIteration
        k = self.it.key
        self.it = self.it.next
        return k DList cmd = stdin.readline() stdin.readline() cmd dlist = DList() DList() dlist n = int(stdin.readline()) int(stdin.readline()) n
from sys import stdin

class DList:
    class Cell:
        def __init__(self, k):
            self.key  = k
            self.prev = None
            self.next = None

    def __init__(self):
        self.head = DList.Cell(None)
        self.last = DList.Cell(None)
        self.head.next = self.last
        self.last.prev = self.head

    def insert(self, x):
        c = DList.Cell(x)
        c.prev = self.head
        c.next = self.head.next
        c.next.prev = c
        self.head.next = c

    def delete(self, x):
        c = self.__find(x)
        if c != None:
            self.__delete(c)

    def __delete(self, c):
        c.prev.next = c.next
        c.next.prev = c.prev

    def __find(self, x):
        c = self.head.next
        while c != None and c.key != x:
            c = c.next
        return c

    def deleteFirst(self):
        self.__delete(self.head.next)
    def deleteLast(self):
        self.__delete(self.last.prev)

    def __iter__(self):
        self.it = self.head.next
        return self
    def __next__(self):
        if self.it == self.last:
            raise StopIteration
        k = self.it.key
        self.it = self.it.next
        return k

dlist = DList()

n = int(stdin.readline())
for i in range(n):
    cmd = stdin.readline()
    if   cmd.startswith('insert'):
        dlist.insert(cmd[7:-1])
    elif cmd.startswith('deleteFirst'):
        dlist.deleteFirst()
    elif cmd.startswith('deleteLast'):
        dlist.deleteLast()
    elif cmd.startswith('delete'):
        dlist.delete(cmd[7:-1])

print(' '.join(dlist))

