from collections import deque

n = int(input())
dll = deque([])

for _ in range(n):
    p = input().split()

    if   p[0] == "insert":
        dll.appendleft(p[1])

    elif p[0] == "delete":
        try:
            dll.remove(p[1])
        except:
            pass

    elif p[0] == "deleteFirst":
        dll.popleft()

    else:
        dll.pop()

print(" ".join(dll)) from collections import deque n = int(input()) n int(input()) int input() input dll = deque([]) dll deque([]) deque [] for _ in range(n):
    p = input().split()

    if   p[0] == "insert":
        dll.appendleft(p[1])

    elif p[0] == "delete":
        try:
            dll.remove(p[1])
        except:
            pass

    elif p[0] == "deleteFirst":
        dll.popleft()

    else:
        dll.pop() _ range(n) range n p = input().split() p input().split() ().split () input split if   p[0] == "insert":
        dll.appendleft(p[1])

    elif p[0] == "delete":
        try:
            dll.remove(p[1])
        except:
            pass

    elif p[0] == "deleteFirst":
        dll.popleft()

    else:
        dll.pop() p[0] == "insert" p[0] p 0 "insert" dll.appendleft(p[1]) dll.appendleft dll appendleft p[1] p 1 elif p[0] == "delete":
        try:
            dll.remove(p[1])
        except:
            pass

     p[0] == "delete" p[0] p 0 "delete" try:
            dll.remove(p[1])
        except:
            pass

     except:
            pass

     dll.remove(p[1]) dll.remove dll remove p[1] p 1 elif p[0] == "deleteFirst":
        dll.popleft()

     p[0] == "deleteFirst" p[0] p 0 "deleteFirst" dll.popleft() dll.popleft dll popleft dll.pop() dll.pop dll pop print(" ".join(dll)) print " ".join(dll) " ".join " " join dll n = int(input()) int(input()) n dll = deque([]) deque([]) dll p = input().split() input().split() p
from collections import deque

n = int(input())
dll = deque([])

for _ in range(n):
    p = input().split()

    if   p[0] == "insert":
        dll.appendleft(p[1])

    elif p[0] == "delete":
        try:
            dll.remove(p[1])
        except:
            pass

    elif p[0] == "deleteFirst":
        dll.popleft()

    else:
        dll.pop()

print(" ".join(dll))
