from collections import deque


def main():
    doubly_liked_list = deque()
    n = int(input())
    for i in range(n):
        command = input()
        if command == 'deleteFirst':
            doubly_liked_list.popleft()
        elif command == 'deleteLast':
            doubly_liked_list.pop()
        else:
            command = command.split()
            if command[0] == 'insert':
                doubly_liked_list.appendleft(int(command[1]))
            elif command[0] == 'delete':
                try:
                    doubly_liked_list.remove(int(command[1]))
                except:
                    pass
    print(*doubly_liked_list)


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


def main():
    doubly_liked_list = deque()
    n = int(input())
    for i in range(n):
        command = input()
        if command == 'deleteFirst':
            doubly_liked_list.popleft()
        elif command == 'deleteLast':
            doubly_liked_list.pop()
        else:
            command = command.split()
            if command[0] == 'insert':
                doubly_liked_list.appendleft(int(command[1]))
            elif command[0] == 'delete':
                try:
                    doubly_liked_list.remove(int(command[1]))
                except:
                    pass
    print(*doubly_liked_list)


if __name__ == "__main__":
    main()

