class Node(object):
    def __init__(self, num, prv = None, nxt = None):
        self.num = num
        self.prv = prv
        self.nxt = nxt
  
  
class DoublyLinkedList(object):
    def __init__(self):
        self.start = self.last = None
  
    def insert(self, num):
        new_elem = Node(num)
  
        if self.start is None:
            self.start = self.last = new_elem
        else:
            new_elem.nxt = self.start
            self.start.prv = new_elem
            self.start = new_elem
  
    def delete_num(self, target):
        it = self.start
        while it is not None:
            if it.num == target:
                if it.prv is None and it.nxt is None:
                    self.start = self.last = None
                else:
                    if it.prv is not None:
                        it.prv.nxt = it.nxt
                    else:
                        self.start = self.start.nxt
  
                    if it.nxt is not None:
                        it.nxt.prv = it.prv
                    else:
                        self.last = self.last.prv
                break
            it = it.nxt
  
    def delete_start(self):
        if self.start is self.last:
            self.start = self.last = None
        else:
            self.start.nxt.prv = None
            self.start = self.start.nxt
  
    def delete_last(self):
        if self.start is self.last:
            self.start = self.last = None
        else:
            self.last.prv.nxt = None
            self.last = self.last.prv
  
    def get_content(self):
        ret = []
        it = self.start
  
        while it is not None:
            ret.append(it.num)
            it = it.nxt
  
        return ' '.join(ret)
  
  
def _main():
    from sys import stdin
  
    n = int(input())
  
    lst = DoublyLinkedList()
      
    for _ in range(n):
        cmd = stdin.readline().strip().split()
        if cmd[0] == 'insert':
            lst.insert(cmd[1])
        elif cmd[0] == 'delete':
            lst.delete_num(cmd[1])
        elif cmd[0] == 'deleteFirst':
            lst.delete_start()
        elif cmd[0] == 'deleteLast':
            lst.delete_last()
  
    print(lst.get_content())
  
  
if __name__ == '__main__':
    _main() class Node(object):
    def __init__(self, num, prv = None, nxt = None):
        self.num = num
        self.prv = prv
        self.nxt = nxt
  
   Node def __init__(self, num, prv = None, nxt = None):
        self.num = num
        self.prv = prv
        self.nxt = nxt
  
   __init__ self.num = num self.num self num num self.prv = prv self.prv self prv prv self.nxt = nxt self.nxt self nxt nxt self self num num prv = None prv None nxt = None nxt None object class DoublyLinkedList(object):
    def __init__(self):
        self.start = self.last = None
  
    def insert(self, num):
        new_elem = Node(num)
  
        if self.start is None:
            self.start = self.last = new_elem
        else:
            new_elem.nxt = self.start
            self.start.prv = new_elem
            self.start = new_elem
  
    def delete_num(self, target):
        it = self.start
        while it is not None:
            if it.num == target:
                if it.prv is None and it.nxt is None:
                    self.start = self.last = None
                else:
                    if it.prv is not None:
                        it.prv.nxt = it.nxt
                    else:
                        self.start = self.start.nxt
  
                    if it.nxt is not None:
                        it.nxt.prv = it.prv
                    else:
                        self.last = self.last.prv
                break
            it = it.nxt
  
    def delete_start(self):
        if self.start is self.last:
            self.start = self.last = None
        else:
            self.start.nxt.prv = None
            self.start = self.start.nxt
  
    def delete_last(self):
        if self.start is self.last:
            self.start = self.last = None
        else:
            self.last.prv.nxt = None
            self.last = self.last.prv
  
    def get_content(self):
        ret = []
        it = self.start
  
        while it is not None:
            ret.append(it.num)
            it = it.nxt
  
        return ' '.join(ret)
  
   DoublyLinkedList def __init__(self):
        self.start = self.last = None
  
     __init__ self.start = self.last = None self.start self start None = self.last = None self.last self last None self self def insert(self, num):
        new_elem = Node(num)
  
        if self.start is None:
            self.start = self.last = new_elem
        else:
            new_elem.nxt = self.start
            self.start.prv = new_elem
            self.start = new_elem
  
     insert new_elem = Node(num) new_elem Node(num) Node num if self.start is None:
            self.start = self.last = new_elem
        else:
            new_elem.nxt = self.start
            self.start.prv = new_elem
            self.start = new_elem
  
     self.start is None self.start self start None self.start = self.last = new_elem self.start self start new_elem = self.last = new_elem self.last self last new_elem new_elem.nxt = self.start new_elem.nxt new_elem nxt self.start self start self.start.prv = new_elem self.start.prv self.start self start prv new_elem self.start = new_elem self.start self start new_elem self self num num def delete_num(self, target):
        it = self.start
        while it is not None:
            if it.num == target:
                if it.prv is None and it.nxt is None:
                    self.start = self.last = None
                else:
                    if it.prv is not None:
                        it.prv.nxt = it.nxt
                    else:
                        self.start = self.start.nxt
  
                    if it.nxt is not None:
                        it.nxt.prv = it.prv
                    else:
                        self.last = self.last.prv
                break
            it = it.nxt
  
     delete_num it = self.start it self.start self start while it is not None:
            if it.num == target:
                if it.prv is None and it.nxt is None:
                    self.start = self.last = None
                else:
                    if it.prv is not None:
                        it.prv.nxt = it.nxt
                    else:
                        self.start = self.start.nxt
  
                    if it.nxt is not None:
                        it.nxt.prv = it.prv
                    else:
                        self.last = self.last.prv
                break
            it = it.nxt
  
     it is not None it None if it.num == target:
                if it.prv is None and it.nxt is None:
                    self.start = self.last = None
                else:
                    if it.prv is not None:
                        it.prv.nxt = it.nxt
                    else:
                        self.start = self.start.nxt
  
                    if it.nxt is not None:
                        it.nxt.prv = it.prv
                    else:
                        self.last = self.last.prv
                break
             it.num == target it.num it num target if it.prv is None and it.nxt is None:
                    self.start = self.last = None
                else:
                    if it.prv is not None:
                        it.prv.nxt = it.nxt
                    else:
                        self.start = self.start.nxt
  
                    if it.nxt is not None:
                        it.nxt.prv = it.prv
                    else:
                        self.last = self.last.prv
                 it.prv is None and it.nxt is None it.prv is None it.prv it prv None it.nxt is None it.nxt it nxt None self.start = self.last = None self.start self start None = self.last = None self.last self last None if it.prv is not None:
                        it.prv.nxt = it.nxt
                    else:
                        self.start = self.start.nxt
  
                     it.prv is not None it.prv it prv None it.prv.nxt = it.nxt it.prv.nxt it.prv it prv nxt it.nxt it nxt self.start = self.start.nxt self.start self start self.start.nxt self.start self start nxt if it.nxt is not None:
                        it.nxt.prv = it.prv
                    else:
                        self.last = self.last.prv
                 it.nxt is not None it.nxt it nxt None it.nxt.prv = it.prv it.nxt.prv it.nxt it nxt prv it.prv it prv self.last = self.last.prv self.last self last self.last.prv self.last self last prv break it = it.nxt it it.nxt it nxt self self target target def delete_start(self):
        if self.start is self.last:
            self.start = self.last = None
        else:
            self.start.nxt.prv = None
            self.start = self.start.nxt
  
     delete_start if self.start is self.last:
            self.start = self.last = None
        else:
            self.start.nxt.prv = None
            self.start = self.start.nxt
  
     self.start is self.last self.start self start self.last self last self.start = self.last = None self.start self start None = self.last = None self.last self last None self.start.nxt.prv = None self.start.nxt.prv self.start.nxt self.start self start nxt prv None self.start = self.start.nxt self.start self start self.start.nxt self.start self start nxt self self def delete_last(self):
        if self.start is self.last:
            self.start = self.last = None
        else:
            self.last.prv.nxt = None
            self.last = self.last.prv
  
     delete_last if self.start is self.last:
            self.start = self.last = None
        else:
            self.last.prv.nxt = None
            self.last = self.last.prv
  
     self.start is self.last self.start self start self.last self last self.start = self.last = None self.start self start None = self.last = None self.last self last None self.last.prv.nxt = None self.last.prv.nxt self.last.prv self.last self last prv nxt None self.last = self.last.prv self.last self last self.last.prv self.last self last prv self self def get_content(self):
        ret = []
        it = self.start
  
        while it is not None:
            ret.append(it.num)
            it = it.nxt
  
        return ' '.join(ret)
  
   get_content ret = [] ret [] it = self.start it self.start self start while it is not None:
            ret.append(it.num)
            it = it.nxt
  
         it is not None it None ret.append(it.num) ret.append ret append it.num it num it = it.nxt it it.nxt it nxt return ' '.join(ret) ' '.join(ret) ' '.join ' ' join ret self self object def _main():
    from sys import stdin
  
    n = int(input())
  
    lst = DoublyLinkedList()
      
    for _ in range(n):
        cmd = stdin.readline().strip().split()
        if cmd[0] == 'insert':
            lst.insert(cmd[1])
        elif cmd[0] == 'delete':
            lst.delete_num(cmd[1])
        elif cmd[0] == 'deleteFirst':
            lst.delete_start()
        elif cmd[0] == 'deleteLast':
            lst.delete_last()
  
    print(lst.get_content())
  
   _main from sys import stdin n = int(input()) n int(input()) int input() input lst = DoublyLinkedList() lst DoublyLinkedList() DoublyLinkedList for _ in range(n):
        cmd = stdin.readline().strip().split()
        if cmd[0] == 'insert':
            lst.insert(cmd[1])
        elif cmd[0] == 'delete':
            lst.delete_num(cmd[1])
        elif cmd[0] == 'deleteFirst':
            lst.delete_start()
        elif cmd[0] == 'deleteLast':
            lst.delete_last()
  
     _ range(n) range n cmd = stdin.readline().strip().split() cmd stdin.readline().strip().split() stdin.readline().strip().split stdin.readline().strip() stdin.readline().strip stdin.readline() stdin.readline stdin readline strip split if cmd[0] == 'insert':
            lst.insert(cmd[1])
        elif cmd[0] == 'delete':
            lst.delete_num(cmd[1])
        elif cmd[0] == 'deleteFirst':
            lst.delete_start()
        elif cmd[0] == 'deleteLast':
            lst.delete_last()
  
     cmd[0] == 'insert' cmd[0] cmd 0 'insert' lst.insert(cmd[1]) lst.insert lst insert cmd[1] cmd 1 elif cmd[0] == 'delete':
            lst.delete_num(cmd[1])
         cmd[0] == 'delete' cmd[0] cmd 0 'delete' lst.delete_num(cmd[1]) lst.delete_num lst delete_num cmd[1] cmd 1 elif cmd[0] == 'deleteFirst':
            lst.delete_start()
         cmd[0] == 'deleteFirst' cmd[0] cmd 0 'deleteFirst' lst.delete_start() lst.delete_start lst delete_start elif cmd[0] == 'deleteLast':
            lst.delete_last()
  
     cmd[0] == 'deleteLast' cmd[0] cmd 0 'deleteLast' lst.delete_last() lst.delete_last lst delete_last print(lst.get_content()) print lst.get_content() lst.get_content lst get_content if __name__ == '__main__':
    _main() __name__ == '__main__' __name__ '__main__' _main() _main class Node(object):
    def __init__(self, num, prv = None, nxt = None):
        self.num = num
        self.prv = prv
        self.nxt = nxt
  
   class Node(object):
    def __init__(self, num, prv = None, nxt = None):
        self.num = num
        self.prv = prv
        self.nxt = nxt
  
   Node class DoublyLinkedList(object):
    def __init__(self):
        self.start = self.last = None
  
    def insert(self, num):
        new_elem = Node(num)
  
        if self.start is None:
            self.start = self.last = new_elem
        else:
            new_elem.nxt = self.start
            self.start.prv = new_elem
            self.start = new_elem
  
    def delete_num(self, target):
        it = self.start
        while it is not None:
            if it.num == target:
                if it.prv is None and it.nxt is None:
                    self.start = self.last = None
                else:
                    if it.prv is not None:
                        it.prv.nxt = it.nxt
                    else:
                        self.start = self.start.nxt
  
                    if it.nxt is not None:
                        it.nxt.prv = it.prv
                    else:
                        self.last = self.last.prv
                break
            it = it.nxt
  
    def delete_start(self):
        if self.start is self.last:
            self.start = self.last = None
        else:
            self.start.nxt.prv = None
            self.start = self.start.nxt
  
    def delete_last(self):
        if self.start is self.last:
            self.start = self.last = None
        else:
            self.last.prv.nxt = None
            self.last = self.last.prv
  
    def get_content(self):
        ret = []
        it = self.start
  
        while it is not None:
            ret.append(it.num)
            it = it.nxt
  
        return ' '.join(ret)
  
   class DoublyLinkedList(object):
    def __init__(self):
        self.start = self.last = None
  
    def insert(self, num):
        new_elem = Node(num)
  
        if self.start is None:
            self.start = self.last = new_elem
        else:
            new_elem.nxt = self.start
            self.start.prv = new_elem
            self.start = new_elem
  
    def delete_num(self, target):
        it = self.start
        while it is not None:
            if it.num == target:
                if it.prv is None and it.nxt is None:
                    self.start = self.last = None
                else:
                    if it.prv is not None:
                        it.prv.nxt = it.nxt
                    else:
                        self.start = self.start.nxt
  
                    if it.nxt is not None:
                        it.nxt.prv = it.prv
                    else:
                        self.last = self.last.prv
                break
            it = it.nxt
  
    def delete_start(self):
        if self.start is self.last:
            self.start = self.last = None
        else:
            self.start.nxt.prv = None
            self.start = self.start.nxt
  
    def delete_last(self):
        if self.start is self.last:
            self.start = self.last = None
        else:
            self.last.prv.nxt = None
            self.last = self.last.prv
  
    def get_content(self):
        ret = []
        it = self.start
  
        while it is not None:
            ret.append(it.num)
            it = it.nxt
  
        return ' '.join(ret)
  
   DoublyLinkedList def _main():
    from sys import stdin
  
    n = int(input())
  
    lst = DoublyLinkedList()
      
    for _ in range(n):
        cmd = stdin.readline().strip().split()
        if cmd[0] == 'insert':
            lst.insert(cmd[1])
        elif cmd[0] == 'delete':
            lst.delete_num(cmd[1])
        elif cmd[0] == 'deleteFirst':
            lst.delete_start()
        elif cmd[0] == 'deleteLast':
            lst.delete_last()
  
    print(lst.get_content())
  
   def _main():
    from sys import stdin
  
    n = int(input())
  
    lst = DoublyLinkedList()
      
    for _ in range(n):
        cmd = stdin.readline().strip().split()
        if cmd[0] == 'insert':
            lst.insert(cmd[1])
        elif cmd[0] == 'delete':
            lst.delete_num(cmd[1])
        elif cmd[0] == 'deleteFirst':
            lst.delete_start()
        elif cmd[0] == 'deleteLast':
            lst.delete_last()
  
    print(lst.get_content())
  
   _main
class Node(object):
    def __init__(self, num, prv = None, nxt = None):
        self.num = num
        self.prv = prv
        self.nxt = nxt
  
  
class DoublyLinkedList(object):
    def __init__(self):
        self.start = self.last = None
  
    def insert(self, num):
        new_elem = Node(num)
  
        if self.start is None:
            self.start = self.last = new_elem
        else:
            new_elem.nxt = self.start
            self.start.prv = new_elem
            self.start = new_elem
  
    def delete_num(self, target):
        it = self.start
        while it is not None:
            if it.num == target:
                if it.prv is None and it.nxt is None:
                    self.start = self.last = None
                else:
                    if it.prv is not None:
                        it.prv.nxt = it.nxt
                    else:
                        self.start = self.start.nxt
  
                    if it.nxt is not None:
                        it.nxt.prv = it.prv
                    else:
                        self.last = self.last.prv
                break
            it = it.nxt
  
    def delete_start(self):
        if self.start is self.last:
            self.start = self.last = None
        else:
            self.start.nxt.prv = None
            self.start = self.start.nxt
  
    def delete_last(self):
        if self.start is self.last:
            self.start = self.last = None
        else:
            self.last.prv.nxt = None
            self.last = self.last.prv
  
    def get_content(self):
        ret = []
        it = self.start
  
        while it is not None:
            ret.append(it.num)
            it = it.nxt
  
        return ' '.join(ret)
  
  
def _main():
    from sys import stdin
  
    n = int(input())
  
    lst = DoublyLinkedList()
      
    for _ in range(n):
        cmd = stdin.readline().strip().split()
        if cmd[0] == 'insert':
            lst.insert(cmd[1])
        elif cmd[0] == 'delete':
            lst.delete_num(cmd[1])
        elif cmd[0] == 'deleteFirst':
            lst.delete_start()
        elif cmd[0] == 'deleteLast':
            lst.delete_last()
  
    print(lst.get_content())
  
  
if __name__ == '__main__':
    _main()
