class Node(object):
  def __init__(self, num, prv = None, next = None):
    self.num = num
    self.prv = prv
    self.next = next

class DoublyLinkedList(object):
  def __init__(self):
    self.start = self.last = None

  def insert(self, num):
    new_element = Node(num)

    if self.start is None: # 空の場合
      self.start = self.last = new_element
    else:
      new_element.next = self.start
      self.start.prv = new_element
      self.start = new_element

  def delete(self, target):
    it = self.start
    while it is not None: # 該当する最初のノードを見つける
      if it.num == target:
        if it.prv is None and it.next is None: # ノードが一つだけの時
          self.start = self.last = None
        else:
          if it.prv is not None: # 先頭ではない
            it.prv.next = it.next
          else: # 先頭の場合、先頭の次をstartにする
            self.start = self.start.next
          if it.next is not None:  # 最後ではない場合
            it.next.prv = it.prv
          else: # 最後の場合、最後の一つ前をlastにする
            self.last = self.last.prv
        break
      it = it.next

  def deleteFirst(self):
    if self.start is self.last:
      self.start = self.last = None
    else:
      self.start.next.prv = None
      self.start = self.start.next

  def deleteLast(self):
    if self.start is self.last:
      self.start = self.last = None
    else:
      self.last.prv.next = None
      self.last = self.last.prv

  def contentToArray(self):
    n_list = []
    it  = self.start
    while it is not None:
      n_list.append(it.num)
      it = it.next
    return ' '.join(n_list)

def main():
  from sys import stdin
  N = int(input())

  linkedList = DoublyLinkedList() # インスタンス作成

  for i in range(N):
    command = stdin.readline().rstrip().split()
    if command[0] == 'insert':
      linkedList.insert(command[1])
    elif command[0] == 'delete':
      linkedList.delete(command[1])
    elif command[0] == 'deleteFirst':
      linkedList.deleteFirst()
    elif command[0] == 'deleteLast':
      linkedList.deleteLast()

  print(linkedList.contentToArray())

if __name__ == "__main__":
  main() class Node(object):
  def __init__(self, num, prv = None, next = None):
    self.num = num
    self.prv = prv
    self.next = next Node def __init__(self, num, prv = None, next = None):
    self.num = num
    self.prv = prv
    self.next = next __init__ self.num = num self.num self num num self.prv = prv self.prv self prv prv self.next = next self.next self next next self self num num prv = None prv None next = None next None object class DoublyLinkedList(object):
  def __init__(self):
    self.start = self.last = None

  def insert(self, num):
    new_element = Node(num)

    if self.start is None: # 空の場合
      self.start = self.last = new_element
    else:
      new_element.next = self.start
      self.start.prv = new_element
      self.start = new_element

  def delete(self, target):
    it = self.start
    while it is not None: # 該当する最初のノードを見つける
      if it.num == target:
        if it.prv is None and it.next is None: # ノードが一つだけの時
          self.start = self.last = None
        else:
          if it.prv is not None: # 先頭ではない
            it.prv.next = it.next
          else: # 先頭の場合、先頭の次をstartにする
            self.start = self.start.next
          if it.next is not None:  # 最後ではない場合
            it.next.prv = it.prv
          else: # 最後の場合、最後の一つ前をlastにする
            self.last = self.last.prv
        break
      it = it.next

  def deleteFirst(self):
    if self.start is self.last:
      self.start = self.last = None
    else:
      self.start.next.prv = None
      self.start = self.start.next

  def deleteLast(self):
    if self.start is self.last:
      self.start = self.last = None
    else:
      self.last.prv.next = None
      self.last = self.last.prv

  def contentToArray(self):
    n_list = []
    it  = self.start
    while it is not None:
      n_list.append(it.num)
      it = it.next
    return ' '.join(n_list) 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_element = Node(num)

    if self.start is None: # 空の場合
      self.start = self.last = new_element
    else:
      new_element.next = self.start
      self.start.prv = new_element
      self.start = new_element

   insert new_element = Node(num) new_element Node(num) Node num if self.start is None: # 空の場合
      self.start = self.last = new_element
    else:
      new_element.next = self.start
      self.start.prv = new_element
      self.start = new_element

   self.start is None self.start self start None self.start = self.last = new_element self.start self start new_element = self.last = new_element self.last self last new_element new_element.next = self.start new_element.next new_element next self.start self start self.start.prv = new_element self.start.prv self.start self start prv new_element self.start = new_element self.start self start new_element self self num num def delete(self, target):
    it = self.start
    while it is not None: # 該当する最初のノードを見つける
      if it.num == target:
        if it.prv is None and it.next is None: # ノードが一つだけの時
          self.start = self.last = None
        else:
          if it.prv is not None: # 先頭ではない
            it.prv.next = it.next
          else: # 先頭の場合、先頭の次をstartにする
            self.start = self.start.next
          if it.next is not None:  # 最後ではない場合
            it.next.prv = it.prv
          else: # 最後の場合、最後の一つ前をlastにする
            self.last = self.last.prv
        break
      it = it.next

   delete it = self.start it self.start self start while it is not None: # 該当する最初のノードを見つける
      if it.num == target:
        if it.prv is None and it.next is None: # ノードが一つだけの時
          self.start = self.last = None
        else:
          if it.prv is not None: # 先頭ではない
            it.prv.next = it.next
          else: # 先頭の場合、先頭の次をstartにする
            self.start = self.start.next
          if it.next is not None:  # 最後ではない場合
            it.next.prv = it.prv
          else: # 最後の場合、最後の一つ前をlastにする
            self.last = self.last.prv
        break
      it = it.next

   it is not None it None if it.num == target:
        if it.prv is None and it.next is None: # ノードが一つだけの時
          self.start = self.last = None
        else:
          if it.prv is not None: # 先頭ではない
            it.prv.next = it.next
          else: # 先頭の場合、先頭の次をstartにする
            self.start = self.start.next
          if it.next is not None:  # 最後ではない場合
            it.next.prv = it.prv
          else: # 最後の場合、最後の一つ前をlastにする
            self.last = self.last.prv
        break
       it.num == target it.num it num target if it.prv is None and it.next is None: # ノードが一つだけの時
          self.start = self.last = None
        else:
          if it.prv is not None: # 先頭ではない
            it.prv.next = it.next
          else: # 先頭の場合、先頭の次をstartにする
            self.start = self.start.next
          if it.next is not None:  # 最後ではない場合
            it.next.prv = it.prv
          else: # 最後の場合、最後の一つ前をlastにする
            self.last = self.last.prv
         it.prv is None and it.next is None it.prv is None it.prv it prv None it.next is None it.next it next 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.next = it.next
          else: # 先頭の場合、先頭の次をstartにする
            self.start = self.start.next
           it.prv is not None it.prv it prv None it.prv.next = it.next it.prv.next it.prv it prv next it.next it next self.start = self.start.next self.start self start self.start.next self.start self start next if it.next is not None:  # 最後ではない場合
            it.next.prv = it.prv
          else: # 最後の場合、最後の一つ前をlastにする
            self.last = self.last.prv
         it.next is not None it.next it next None it.next.prv = it.prv it.next.prv it.next it next 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.next it it.next it next self self target target def deleteFirst(self):
    if self.start is self.last:
      self.start = self.last = None
    else:
      self.start.next.prv = None
      self.start = self.start.next

   deleteFirst if self.start is self.last:
      self.start = self.last = None
    else:
      self.start.next.prv = None
      self.start = self.start.next

   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.next.prv = None self.start.next.prv self.start.next self.start self start next prv None self.start = self.start.next self.start self start self.start.next self.start self start next self self def deleteLast(self):
    if self.start is self.last:
      self.start = self.last = None
    else:
      self.last.prv.next = None
      self.last = self.last.prv

   deleteLast if self.start is self.last:
      self.start = self.last = None
    else:
      self.last.prv.next = 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.next = None self.last.prv.next self.last.prv self.last self last prv next None self.last = self.last.prv self.last self last self.last.prv self.last self last prv self self def contentToArray(self):
    n_list = []
    it  = self.start
    while it is not None:
      n_list.append(it.num)
      it = it.next
    return ' '.join(n_list) contentToArray n_list = [] n_list [] it  = self.start it self.start self start while it is not None:
      n_list.append(it.num)
      it = it.next
     it is not None it None n_list.append(it.num) n_list.append n_list append it.num it num it = it.next it it.next it next return ' '.join(n_list) ' '.join(n_list) ' '.join ' ' join n_list self self object def main():
  from sys import stdin
  N = int(input())

  linkedList = DoublyLinkedList() # インスタンス作成

  for i in range(N):
    command = stdin.readline().rstrip().split()
    if command[0] == 'insert':
      linkedList.insert(command[1])
    elif command[0] == 'delete':
      linkedList.delete(command[1])
    elif command[0] == 'deleteFirst':
      linkedList.deleteFirst()
    elif command[0] == 'deleteLast':
      linkedList.deleteLast()

  print(linkedList.contentToArray()) main from sys import stdin N = int(input()) N int(input()) int input() input linkedList = DoublyLinkedList() linkedList DoublyLinkedList() DoublyLinkedList for i in range(N):
    command = stdin.readline().rstrip().split()
    if command[0] == 'insert':
      linkedList.insert(command[1])
    elif command[0] == 'delete':
      linkedList.delete(command[1])
    elif command[0] == 'deleteFirst':
      linkedList.deleteFirst()
    elif command[0] == 'deleteLast':
      linkedList.deleteLast()

   i range(N) range N command = stdin.readline().rstrip().split() command stdin.readline().rstrip().split() stdin.readline().rstrip().split stdin.readline().rstrip() stdin.readline().rstrip stdin.readline() stdin.readline stdin readline rstrip split if command[0] == 'insert':
      linkedList.insert(command[1])
    elif command[0] == 'delete':
      linkedList.delete(command[1])
    elif command[0] == 'deleteFirst':
      linkedList.deleteFirst()
    elif command[0] == 'deleteLast':
      linkedList.deleteLast()

   command[0] == 'insert' command[0] command 0 'insert' linkedList.insert(command[1]) linkedList.insert linkedList insert command[1] command 1 elif command[0] == 'delete':
      linkedList.delete(command[1])
     command[0] == 'delete' command[0] command 0 'delete' linkedList.delete(command[1]) linkedList.delete linkedList delete command[1] command 1 elif command[0] == 'deleteFirst':
      linkedList.deleteFirst()
     command[0] == 'deleteFirst' command[0] command 0 'deleteFirst' linkedList.deleteFirst() linkedList.deleteFirst linkedList deleteFirst elif command[0] == 'deleteLast':
      linkedList.deleteLast()

   command[0] == 'deleteLast' command[0] command 0 'deleteLast' linkedList.deleteLast() linkedList.deleteLast linkedList deleteLast print(linkedList.contentToArray()) print linkedList.contentToArray() linkedList.contentToArray linkedList contentToArray if __name__ == "__main__":
  main() __name__ == "__main__" __name__ "__main__" main() main class Node(object):
  def __init__(self, num, prv = None, next = None):
    self.num = num
    self.prv = prv
    self.next = next class Node(object):
  def __init__(self, num, prv = None, next = None):
    self.num = num
    self.prv = prv
    self.next = next Node def main():
  from sys import stdin
  N = int(input())

  linkedList = DoublyLinkedList() # インスタンス作成

  for i in range(N):
    command = stdin.readline().rstrip().split()
    if command[0] == 'insert':
      linkedList.insert(command[1])
    elif command[0] == 'delete':
      linkedList.delete(command[1])
    elif command[0] == 'deleteFirst':
      linkedList.deleteFirst()
    elif command[0] == 'deleteLast':
      linkedList.deleteLast()

  print(linkedList.contentToArray()) def main():
  from sys import stdin
  N = int(input())

  linkedList = DoublyLinkedList() # インスタンス作成

  for i in range(N):
    command = stdin.readline().rstrip().split()
    if command[0] == 'insert':
      linkedList.insert(command[1])
    elif command[0] == 'delete':
      linkedList.delete(command[1])
    elif command[0] == 'deleteFirst':
      linkedList.deleteFirst()
    elif command[0] == 'deleteLast':
      linkedList.deleteLast()

  print(linkedList.contentToArray()) main class DoublyLinkedList(object):
  def __init__(self):
    self.start = self.last = None

  def insert(self, num):
    new_element = Node(num)

    if self.start is None: # 空の場合
      self.start = self.last = new_element
    else:
      new_element.next = self.start
      self.start.prv = new_element
      self.start = new_element

  def delete(self, target):
    it = self.start
    while it is not None: # 該当する最初のノードを見つける
      if it.num == target:
        if it.prv is None and it.next is None: # ノードが一つだけの時
          self.start = self.last = None
        else:
          if it.prv is not None: # 先頭ではない
            it.prv.next = it.next
          else: # 先頭の場合、先頭の次をstartにする
            self.start = self.start.next
          if it.next is not None:  # 最後ではない場合
            it.next.prv = it.prv
          else: # 最後の場合、最後の一つ前をlastにする
            self.last = self.last.prv
        break
      it = it.next

  def deleteFirst(self):
    if self.start is self.last:
      self.start = self.last = None
    else:
      self.start.next.prv = None
      self.start = self.start.next

  def deleteLast(self):
    if self.start is self.last:
      self.start = self.last = None
    else:
      self.last.prv.next = None
      self.last = self.last.prv

  def contentToArray(self):
    n_list = []
    it  = self.start
    while it is not None:
      n_list.append(it.num)
      it = it.next
    return ' '.join(n_list) class DoublyLinkedList(object):
  def __init__(self):
    self.start = self.last = None

  def insert(self, num):
    new_element = Node(num)

    if self.start is None: # 空の場合
      self.start = self.last = new_element
    else:
      new_element.next = self.start
      self.start.prv = new_element
      self.start = new_element

  def delete(self, target):
    it = self.start
    while it is not None: # 該当する最初のノードを見つける
      if it.num == target:
        if it.prv is None and it.next is None: # ノードが一つだけの時
          self.start = self.last = None
        else:
          if it.prv is not None: # 先頭ではない
            it.prv.next = it.next
          else: # 先頭の場合、先頭の次をstartにする
            self.start = self.start.next
          if it.next is not None:  # 最後ではない場合
            it.next.prv = it.prv
          else: # 最後の場合、最後の一つ前をlastにする
            self.last = self.last.prv
        break
      it = it.next

  def deleteFirst(self):
    if self.start is self.last:
      self.start = self.last = None
    else:
      self.start.next.prv = None
      self.start = self.start.next

  def deleteLast(self):
    if self.start is self.last:
      self.start = self.last = None
    else:
      self.last.prv.next = None
      self.last = self.last.prv

  def contentToArray(self):
    n_list = []
    it  = self.start
    while it is not None:
      n_list.append(it.num)
      it = it.next
    return ' '.join(n_list) DoublyLinkedList
class Node(object):
  def __init__(self, num, prv = None, next = None):
    self.num = num
    self.prv = prv
    self.next = next

class DoublyLinkedList(object):
  def __init__(self):
    self.start = self.last = None

  def insert(self, num):
    new_element = Node(num)

    if self.start is None: # 空の場合
      self.start = self.last = new_element
    else:
      new_element.next = self.start
      self.start.prv = new_element
      self.start = new_element

  def delete(self, target):
    it = self.start
    while it is not None: # 該当する最初のノードを見つける
      if it.num == target:
        if it.prv is None and it.next is None: # ノードが一つだけの時
          self.start = self.last = None
        else:
          if it.prv is not None: # 先頭ではない
            it.prv.next = it.next
          else: # 先頭の場合、先頭の次をstartにする
            self.start = self.start.next
          if it.next is not None:  # 最後ではない場合
            it.next.prv = it.prv
          else: # 最後の場合、最後の一つ前をlastにする
            self.last = self.last.prv
        break
      it = it.next

  def deleteFirst(self):
    if self.start is self.last:
      self.start = self.last = None
    else:
      self.start.next.prv = None
      self.start = self.start.next

  def deleteLast(self):
    if self.start is self.last:
      self.start = self.last = None
    else:
      self.last.prv.next = None
      self.last = self.last.prv

  def contentToArray(self):
    n_list = []
    it  = self.start
    while it is not None:
      n_list.append(it.num)
      it = it.next
    return ' '.join(n_list)

def main():
  from sys import stdin
  N = int(input())

  linkedList = DoublyLinkedList() # インスタンス作成

  for i in range(N):
    command = stdin.readline().rstrip().split()
    if command[0] == 'insert':
      linkedList.insert(command[1])
    elif command[0] == 'delete':
      linkedList.delete(command[1])
    elif command[0] == 'deleteFirst':
      linkedList.deleteFirst()
    elif command[0] == 'deleteLast':
      linkedList.deleteLast()

  print(linkedList.contentToArray())

if __name__ == "__main__":
  main()
