from collections import deque

n = int(input())
A = deque()

for i in range(n):
  order = input().split()
  if order[0] == "insert":
    A.appendleft(order[1])
  elif order[0] == "delete":
    try:
      A.remove(order[1])
    except ValueError:
      pass
  elif order[0] == "deleteFirst":
    A.popleft()
  elif order[0] == "deleteLast":
    A.pop()

print(" ".join(map(str, A)))
 from collections import deque n = int(input()) n int(input()) int input() input A = deque() A deque() deque for i in range(n):
  order = input().split()
  if order[0] == "insert":
    A.appendleft(order[1])
  elif order[0] == "delete":
    try:
      A.remove(order[1])
    except ValueError:
      pass
  elif order[0] == "deleteFirst":
    A.popleft()
  elif order[0] == "deleteLast":
    A.pop() i range(n) range n order = input().split() order input().split() ().split () input split if order[0] == "insert":
    A.appendleft(order[1])
  elif order[0] == "delete":
    try:
      A.remove(order[1])
    except ValueError:
      pass
  elif order[0] == "deleteFirst":
    A.popleft()
  elif order[0] == "deleteLast":
    A.pop() order[0] == "insert" order[0] order 0 "insert" A.appendleft(order[1]) A.appendleft A appendleft order[1] order 1 elif order[0] == "delete":
    try:
      A.remove(order[1])
    except ValueError:
      pass
   order[0] == "delete" order[0] order 0 "delete" try:
      A.remove(order[1])
    except ValueError:
      pass
   except ValueError:
      pass
   A.remove(order[1]) A.remove A remove order[1] order 1 elif order[0] == "deleteFirst":
    A.popleft()
   order[0] == "deleteFirst" order[0] order 0 "deleteFirst" A.popleft() A.popleft A popleft elif order[0] == "deleteLast":
    A.pop() order[0] == "deleteLast" order[0] order 0 "deleteLast" A.pop() A.pop A pop print(" ".join(map(str, A))) print " ".join(map(str, A)) " ".join " " join map(str, A) map str A n = int(input()) int(input()) n order = input().split() input().split() order A = deque() deque() A
from collections import deque

n = int(input())
A = deque()

for i in range(n):
  order = input().split()
  if order[0] == "insert":
    A.appendleft(order[1])
  elif order[0] == "delete":
    try:
      A.remove(order[1])
    except ValueError:
      pass
  elif order[0] == "deleteFirst":
    A.popleft()
  elif order[0] == "deleteLast":
    A.pop()

print(" ".join(map(str, A)))

