from collections import deque

def main():

    queue = deque()

    for _ in range(int(input())):
        commands = input().split(" ")
        if commands[0] == "insert":
            queue.appendleft(commands[1])
        elif commands[0] == "delete":
            try:
                queue.remove(commands[1])
            except ValueError:
                pass
        elif commands[0] == "deleteFirst":
            queue.popleft()
        elif commands[0] == "deleteLast":
            queue.pop()

    print(" ".join(queue))

main() from collections import deque def main():

    queue = deque()

    for _ in range(int(input())):
        commands = input().split(" ")
        if commands[0] == "insert":
            queue.appendleft(commands[1])
        elif commands[0] == "delete":
            try:
                queue.remove(commands[1])
            except ValueError:
                pass
        elif commands[0] == "deleteFirst":
            queue.popleft()
        elif commands[0] == "deleteLast":
            queue.pop()

    print(" ".join(queue)) main queue = deque() queue deque() deque for _ in range(int(input())):
        commands = input().split(" ")
        if commands[0] == "insert":
            queue.appendleft(commands[1])
        elif commands[0] == "delete":
            try:
                queue.remove(commands[1])
            except ValueError:
                pass
        elif commands[0] == "deleteFirst":
            queue.popleft()
        elif commands[0] == "deleteLast":
            queue.pop()

     _ range(int(input())) range int(input()) int input() input commands = input().split(" ") commands input().split(" ") ().split () input split " " if commands[0] == "insert":
            queue.appendleft(commands[1])
        elif commands[0] == "delete":
            try:
                queue.remove(commands[1])
            except ValueError:
                pass
        elif commands[0] == "deleteFirst":
            queue.popleft()
        elif commands[0] == "deleteLast":
            queue.pop()

     commands[0] == "insert" commands[0] commands 0 "insert" queue.appendleft(commands[1]) queue.appendleft queue appendleft commands[1] commands 1 elif commands[0] == "delete":
            try:
                queue.remove(commands[1])
            except ValueError:
                pass
         commands[0] == "delete" commands[0] commands 0 "delete" try:
                queue.remove(commands[1])
            except ValueError:
                pass
         except ValueError:
                pass
         queue.remove(commands[1]) queue.remove queue remove commands[1] commands 1 elif commands[0] == "deleteFirst":
            queue.popleft()
         commands[0] == "deleteFirst" commands[0] commands 0 "deleteFirst" queue.popleft() queue.popleft queue popleft elif commands[0] == "deleteLast":
            queue.pop()

     commands[0] == "deleteLast" commands[0] commands 0 "deleteLast" queue.pop() queue.pop queue pop print(" ".join(queue)) print " ".join(queue) " ".join " " join queue main() main def main():

    queue = deque()

    for _ in range(int(input())):
        commands = input().split(" ")
        if commands[0] == "insert":
            queue.appendleft(commands[1])
        elif commands[0] == "delete":
            try:
                queue.remove(commands[1])
            except ValueError:
                pass
        elif commands[0] == "deleteFirst":
            queue.popleft()
        elif commands[0] == "deleteLast":
            queue.pop()

    print(" ".join(queue)) def main():

    queue = deque()

    for _ in range(int(input())):
        commands = input().split(" ")
        if commands[0] == "insert":
            queue.appendleft(commands[1])
        elif commands[0] == "delete":
            try:
                queue.remove(commands[1])
            except ValueError:
                pass
        elif commands[0] == "deleteFirst":
            queue.popleft()
        elif commands[0] == "deleteLast":
            queue.pop()

    print(" ".join(queue)) main
from collections import deque

def main():

    queue = deque()

    for _ in range(int(input())):
        commands = input().split(" ")
        if commands[0] == "insert":
            queue.appendleft(commands[1])
        elif commands[0] == "delete":
            try:
                queue.remove(commands[1])
            except ValueError:
                pass
        elif commands[0] == "deleteFirst":
            queue.popleft()
        elif commands[0] == "deleteLast":
            queue.pop()

    print(" ".join(queue))

main()