from collections import deque

if __name__ == '__main__':
    n = int(input())
    dll = deque()
    for _ in range(n):
        command = input().split()
        if command[0] == 'insert':
            dll.appendleft(command[1])
        elif command[0] == 'delete':
            try:
                dll.remove(command[1])
            except ValueError:
                pass
        elif command[0] == 'deleteFirst':
            dll.popleft()
        elif command[0] == 'deleteLast':
            dll.pop()
    print(*dll) from collections import deque if __name__ == '__main__':
    n = int(input())
    dll = deque()
    for _ in range(n):
        command = input().split()
        if command[0] == 'insert':
            dll.appendleft(command[1])
        elif command[0] == 'delete':
            try:
                dll.remove(command[1])
            except ValueError:
                pass
        elif command[0] == 'deleteFirst':
            dll.popleft()
        elif command[0] == 'deleteLast':
            dll.pop()
    print(*dll) __name__ == '__main__' __name__ '__main__' n = int(input()) n int(input()) int input() input dll = deque() dll deque() deque for _ in range(n):
        command = input().split()
        if command[0] == 'insert':
            dll.appendleft(command[1])
        elif command[0] == 'delete':
            try:
                dll.remove(command[1])
            except ValueError:
                pass
        elif command[0] == 'deleteFirst':
            dll.popleft()
        elif command[0] == 'deleteLast':
            dll.pop()
     _ range(n) range n command = input().split() command input().split() ().split () input split if command[0] == 'insert':
            dll.appendleft(command[1])
        elif command[0] == 'delete':
            try:
                dll.remove(command[1])
            except ValueError:
                pass
        elif command[0] == 'deleteFirst':
            dll.popleft()
        elif command[0] == 'deleteLast':
            dll.pop()
     command[0] == 'insert' command[0] command 0 'insert' dll.appendleft(command[1]) dll.appendleft dll appendleft command[1] command 1 elif command[0] == 'delete':
            try:
                dll.remove(command[1])
            except ValueError:
                pass
         command[0] == 'delete' command[0] command 0 'delete' try:
                dll.remove(command[1])
            except ValueError:
                pass
         except ValueError:
                pass
         dll.remove(command[1]) dll.remove dll remove command[1] command 1 elif command[0] == 'deleteFirst':
            dll.popleft()
         command[0] == 'deleteFirst' command[0] command 0 'deleteFirst' dll.popleft() dll.popleft dll popleft elif command[0] == 'deleteLast':
            dll.pop()
     command[0] == 'deleteLast' command[0] command 0 'deleteLast' dll.pop() dll.pop dll pop print(*dll) print *dll dll n = int(input()) int(input()) n dll = deque() deque() dll command = input().split() input().split() command
from collections import deque

if __name__ == '__main__':
    n = int(input())
    dll = deque()
    for _ in range(n):
        command = input().split()
        if command[0] == 'insert':
            dll.appendleft(command[1])
        elif command[0] == 'delete':
            try:
                dll.remove(command[1])
            except ValueError:
                pass
        elif command[0] == 'deleteFirst':
            dll.popleft()
        elif command[0] == 'deleteLast':
            dll.pop()
    print(*dll)
