from collections import deque

q = deque()

for i in range(int(input())):
  command_line = input().split(" ")
  command = command_line[0]
  arg = ""
  if len(command_line) > 1: arg = command_line[1]

  if command == "insert":
    q.appendleft(arg)
  elif command == "delete":
    try:
      q.remove(arg)
    except ValueError:
      pass
  elif command == "deleteFirst":
    q.popleft()
  else:
    q.pop()

print(" ".join(q)) from collections import deque q = deque() q deque() deque for i in range(int(input())):
  command_line = input().split(" ")
  command = command_line[0]
  arg = ""
  if len(command_line) > 1: arg = command_line[1]

  if command == "insert":
    q.appendleft(arg)
  elif command == "delete":
    try:
      q.remove(arg)
    except ValueError:
      pass
  elif command == "deleteFirst":
    q.popleft()
  else:
    q.pop() i range(int(input())) range int(input()) int input() input command_line = input().split(" ") command_line input().split(" ") ().split () input split " " command = command_line[0] command command_line[0] command_line 0 arg = "" arg "" if len(command_line) > 1: arg = command_line[1]

   len(command_line) > 1 len(command_line) len command_line 1 if command == "insert":
    q.appendleft(arg)
  elif command == "delete":
    try:
      q.remove(arg)
    except ValueError:
      pass
  elif command == "deleteFirst":
    q.popleft()
  else:
    q.pop() command == "insert" command "insert" q.appendleft(arg) q.appendleft q appendleft arg elif command == "delete":
    try:
      q.remove(arg)
    except ValueError:
      pass
   command == "delete" command "delete" try:
      q.remove(arg)
    except ValueError:
      pass
   except ValueError:
      pass
   q.remove(arg) q.remove q remove arg elif command == "deleteFirst":
    q.popleft()
   command == "deleteFirst" command "deleteFirst" q.popleft() q.popleft q popleft q.pop() q.pop q pop print(" ".join(q)) print " ".join(q) " ".join " " join q q = deque() deque() q command = command_line[0] command_line[0] command command_line = input().split(" ") input().split(" ") command_line arg = "" "" arg
from collections import deque

q = deque()

for i in range(int(input())):
  command_line = input().split(" ")
  command = command_line[0]
  arg = ""
  if len(command_line) > 1: arg = command_line[1]

  if command == "insert":
    q.appendleft(arg)
  elif command == "delete":
    try:
      q.remove(arg)
    except ValueError:
      pass
  elif command == "deleteFirst":
    q.popleft()
  else:
    q.pop()

print(" ".join(q))