output_description: Print all the element (key) in the list after the given operations. Two
  consequtive keys should be separated by a single space.
input_description: The input is given in the following format:
  
  _n_  
  _command_ 1  
  _command_ 2  
  ...  
  _command n_  
  
  In the first line, the number of operations _n_ is given. In the following _n_
  lines, the above mentioned operations are given in the following format:
  
    * insert x
    * delete x
    * deleteFirst 
    * deleteLast
attempt: # http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_C&lang=jp
  sample_input = list(range(3))
  sample_input[
      0
  ] = """7
  insert 5
  insert 2
  insert 3
  insert 1
  delete 3
  insert 6
  delete 5"""
  sample_input[
      1
  ] = """9
  insert 5
  insert 2
  insert 3
  insert 1
  delete 3
  insert 6
  delete 5
  deleteFirst
  deleteLast"""
  sample_input[2] = """"""
  give_sample_input = None
  if give_sample_input is not None:
      sample_input_list = sample_input[give_sample_input].split("\n")
  
      def input():
          return sample_input_list.pop(0)
  
  
  # main
  class DoublyLinkedList:
  
      def __init__(self, a_data=[]):
          self.data = a_data
  
      def insert(self, x):
          self.data.insert(0, x)
  
      def delete(self, x):
          self.data.remove(x)
  
      def delete_first(self):
          self.data.pop(0)
  
      def delete_last(self):
          self.data.pop()
  
      def to_str(self):
          output = ""
          for x in self.data:
              output += str(x) + " "
          output = output.rstrip()
          return output
  
  
  num_of_command = int(input())
  doublely_list = DoublyLinkedList()
  for n in range(num_of_command):
      str_command = input()
      if str_command == "deleteFirst":
          doublely_list.delete_first()
          continue
      elif str_command == "deleteLast":
          doublely_list.delete_last()
          continue
      command_name = str_command.split()[0]
      command_obj = int(str_command.split()[1])
      if command_name == "insert":
          doublely_list.insert(command_obj)
      elif command_name == "delete":
          doublely_list.delete(command_obj)
  
  print(doublely_list.to_str())
  
problem_description: Doubly Linked List
  
  Your task is to implement a double linked list.
  
  Write a program which performs the following operations:
  
    * insert x: insert an element with key x into the front of the list.
    * delete x: delete the first element which has the key of x from the list. If there is not such element, you need not do anything.
    * deleteFirst: delete the first element from the list. 
    * deleteLast: delete the last element from the list.
samples: [{"input": "7\n    insert 5\n    insert 2\n    insert 3\n    insert 1\n    delete 3\n    insert 6\n    delete 5", "output": "6 1 2"}, {"input": "9\n    insert 5\n    insert 2\n    insert 3\n    insert 1\n    delete 3\n    insert 6\n    delete 5\n    deleteFirst\n    deleteLast", "output": "1"}]