# coding: UTF-8
from collections import deque

dll = deque()

n = int(input())
for _ in range(n):
  raw = input().split()
  command = raw[0]
  if command == 'delete': 
    value = raw[1]
    try:
      dll.remove(value)
    except ValueError as err:
      continue
  elif command == 'insert':
    value = raw[1]
    dll.appendleft(value)
  elif command == 'deleteFirst':
    try:
      dll.popleft()
    except IndexError as err:
      continue
  elif command == 'deleteLast':
    try:
      dll.pop()
    except IndexError as err:
      continue

print(" ".join(dll)) from collections import deque dll = deque() dll deque() deque n = int(input()) n int(input()) int input() input for _ in range(n):
  raw = input().split()
  command = raw[0]
  if command == 'delete': 
    value = raw[1]
    try:
      dll.remove(value)
    except ValueError as err:
      continue
  elif command == 'insert':
    value = raw[1]
    dll.appendleft(value)
  elif command == 'deleteFirst':
    try:
      dll.popleft()
    except IndexError as err:
      continue
  elif command == 'deleteLast':
    try:
      dll.pop()
    except IndexError as err:
      continue _ range(n) range n raw = input().split() raw input().split() ().split () input split command = raw[0] command raw[0] raw 0 if command == 'delete': 
    value = raw[1]
    try:
      dll.remove(value)
    except ValueError as err:
      continue
  elif command == 'insert':
    value = raw[1]
    dll.appendleft(value)
  elif command == 'deleteFirst':
    try:
      dll.popleft()
    except IndexError as err:
      continue
  elif command == 'deleteLast':
    try:
      dll.pop()
    except IndexError as err:
      continue command == 'delete' command 'delete' value = raw[1] value raw[1] raw 1 try:
      dll.remove(value)
    except ValueError as err:
      continue
   except ValueError as err:
      continue
   continue dll.remove(value) dll.remove dll remove value elif command == 'insert':
    value = raw[1]
    dll.appendleft(value)
   command == 'insert' command 'insert' value = raw[1] value raw[1] raw 1 dll.appendleft(value) dll.appendleft dll appendleft value elif command == 'deleteFirst':
    try:
      dll.popleft()
    except IndexError as err:
      continue
   command == 'deleteFirst' command 'deleteFirst' try:
      dll.popleft()
    except IndexError as err:
      continue
   except IndexError as err:
      continue
   continue dll.popleft() dll.popleft dll popleft elif command == 'deleteLast':
    try:
      dll.pop()
    except IndexError as err:
      continue command == 'deleteLast' command 'deleteLast' try:
      dll.pop()
    except IndexError as err:
      continue except IndexError as err:
      continue continue dll.pop() dll.pop dll pop print(" ".join(dll)) print " ".join(dll) " ".join " " join dll command = raw[0] raw[0] command value = raw[1] raw[1] value raw = input().split() input().split() raw dll = deque() deque() dll value = raw[1] raw[1] value n = int(input()) int(input()) n
# coding: UTF-8
from collections import deque

dll = deque()

n = int(input())
for _ in range(n):
  raw = input().split()
  command = raw[0]
  if command == 'delete': 
    value = raw[1]
    try:
      dll.remove(value)
    except ValueError as err:
      continue
  elif command == 'insert':
    value = raw[1]
    dll.appendleft(value)
  elif command == 'deleteFirst':
    try:
      dll.popleft()
    except IndexError as err:
      continue
  elif command == 'deleteLast':
    try:
      dll.pop()
    except IndexError as err:
      continue

print(" ".join(dll))
