import math
import sys
import itertools
from collections import deque
# import numpy as np

def main():
  n = int(input())

  d = deque()
  for _ in range(n):
    order = input().split()

    if order[0] == 'insert':
      d.appendleft(order[1])
    elif order[0] == 'delete':
      try:
        d.remove(order[1])
      except ValueError:
        pass
    elif order[0] == 'deleteFirst':
      d.popleft()
    elif order[0] == 'deleteLast':
      d.pop()

  print(*d)

if __name__ == '__main__':
  main() import math math import sys sys import itertools itertools from collections import deque def main():
  n = int(input())

  d = deque()
  for _ in range(n):
    order = input().split()

    if order[0] == 'insert':
      d.appendleft(order[1])
    elif order[0] == 'delete':
      try:
        d.remove(order[1])
      except ValueError:
        pass
    elif order[0] == 'deleteFirst':
      d.popleft()
    elif order[0] == 'deleteLast':
      d.pop()

  print(*d) main n = int(input()) n int(input()) int input() input d = deque() d deque() deque for _ in range(n):
    order = input().split()

    if order[0] == 'insert':
      d.appendleft(order[1])
    elif order[0] == 'delete':
      try:
        d.remove(order[1])
      except ValueError:
        pass
    elif order[0] == 'deleteFirst':
      d.popleft()
    elif order[0] == 'deleteLast':
      d.pop()

   _ range(n) range n order = input().split() order input().split() ().split () input split if order[0] == 'insert':
      d.appendleft(order[1])
    elif order[0] == 'delete':
      try:
        d.remove(order[1])
      except ValueError:
        pass
    elif order[0] == 'deleteFirst':
      d.popleft()
    elif order[0] == 'deleteLast':
      d.pop()

   order[0] == 'insert' order[0] order 0 'insert' d.appendleft(order[1]) d.appendleft d appendleft order[1] order 1 elif order[0] == 'delete':
      try:
        d.remove(order[1])
      except ValueError:
        pass
     order[0] == 'delete' order[0] order 0 'delete' try:
        d.remove(order[1])
      except ValueError:
        pass
     except ValueError:
        pass
     d.remove(order[1]) d.remove d remove order[1] order 1 elif order[0] == 'deleteFirst':
      d.popleft()
     order[0] == 'deleteFirst' order[0] order 0 'deleteFirst' d.popleft() d.popleft d popleft elif order[0] == 'deleteLast':
      d.pop()

   order[0] == 'deleteLast' order[0] order 0 'deleteLast' d.pop() d.pop d pop print(*d) print *d d if __name__ == '__main__':
  main() __name__ == '__main__' __name__ '__main__' main() main def main():
  n = int(input())

  d = deque()
  for _ in range(n):
    order = input().split()

    if order[0] == 'insert':
      d.appendleft(order[1])
    elif order[0] == 'delete':
      try:
        d.remove(order[1])
      except ValueError:
        pass
    elif order[0] == 'deleteFirst':
      d.popleft()
    elif order[0] == 'deleteLast':
      d.pop()

  print(*d) def main():
  n = int(input())

  d = deque()
  for _ in range(n):
    order = input().split()

    if order[0] == 'insert':
      d.appendleft(order[1])
    elif order[0] == 'delete':
      try:
        d.remove(order[1])
      except ValueError:
        pass
    elif order[0] == 'deleteFirst':
      d.popleft()
    elif order[0] == 'deleteLast':
      d.pop()

  print(*d) main
import math
import sys
import itertools
from collections import deque
# import numpy as np

def main():
  n = int(input())

  d = deque()
  for _ in range(n):
    order = input().split()

    if order[0] == 'insert':
      d.appendleft(order[1])
    elif order[0] == 'delete':
      try:
        d.remove(order[1])
      except ValueError:
        pass
    elif order[0] == 'deleteFirst':
      d.popleft()
    elif order[0] == 'deleteLast':
      d.pop()

  print(*d)

if __name__ == '__main__':
  main()
