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: import sys, collections
  
  input = lambda: sys.stdin.readline().rstrip()
  sys.setrecursionlimit(10**7)
  INF = 10**10
  
  
  def I():
      return int(input())
  
  
  def F():
      return float(input())
  
  
  def SS():
      return input()
  
  
  def LI():
      return [int(x) for x in input().split()]
  
  
  def LI_():
      return [int(x) - 1 for x in input().split()]
  
  
  def LF():
      return [float(x) for x in input().split()]
  
  
  def LSS():
      return input().split()
  
  
  def resolve():
      n = I()
      command = [LSS() for _ in range(n)]
  
      que = collections.deque()
      for i in command:
          if i[0] == "insert":
              que.appendleft(i[1])
          elif i[0] == "delete":
              if i[1] in que:
                  que.remove(i[1])
          elif i[0] == "deleteFirst":
              que.popleft()
          elif i[0] == "deleteLast":
              que.pop()
  
      print(*que)
  
  
  if __name__ == "__main__":
      resolve()
  
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"}]