if __name__ == '__main__':
    from collections import deque

    n = int(input())
    A = deque([])
    for i in range(n):
        command = input()
        if command[6] == "F":
            A.popleft()
        elif command[6] == "L":
            A.pop()
        elif command[0] == "i":
            A.appendleft(int(command[7:]))
        else:
            try:
                A.remove(int(command[7:]))
            except ValueError:
                continue

    print(*A)
 if __name__ == '__main__':
    from collections import deque

    n = int(input())
    A = deque([])
    for i in range(n):
        command = input()
        if command[6] == "F":
            A.popleft()
        elif command[6] == "L":
            A.pop()
        elif command[0] == "i":
            A.appendleft(int(command[7:]))
        else:
            try:
                A.remove(int(command[7:]))
            except ValueError:
                continue

    print(*A) __name__ == '__main__' __name__ '__main__' from collections import deque n = int(input()) n int(input()) int input() input A = deque([]) A deque([]) deque [] for i in range(n):
        command = input()
        if command[6] == "F":
            A.popleft()
        elif command[6] == "L":
            A.pop()
        elif command[0] == "i":
            A.appendleft(int(command[7:]))
        else:
            try:
                A.remove(int(command[7:]))
            except ValueError:
                continue

     i range(n) range n command = input() command input() input if command[6] == "F":
            A.popleft()
        elif command[6] == "L":
            A.pop()
        elif command[0] == "i":
            A.appendleft(int(command[7:]))
        else:
            try:
                A.remove(int(command[7:]))
            except ValueError:
                continue

     command[6] == "F" command[6] command 6 "F" A.popleft() A.popleft A popleft elif command[6] == "L":
            A.pop()
         command[6] == "L" command[6] command 6 "L" A.pop() A.pop A pop elif command[0] == "i":
            A.appendleft(int(command[7:]))
         command[0] == "i" command[0] command 0 "i" A.appendleft(int(command[7:])) A.appendleft A appendleft int(command[7:]) int command[7:] command 7: 7 try:
                A.remove(int(command[7:]))
            except ValueError:
                continue

     except ValueError:
                continue

     continue A.remove(int(command[7:])) A.remove A remove int(command[7:]) int command[7:] command 7: 7 print(*A) print *A A command = input() input() command n = int(input()) int(input()) n A = deque([]) deque([]) A
if __name__ == '__main__':
    from collections import deque

    n = int(input())
    A = deque([])
    for i in range(n):
        command = input()
        if command[6] == "F":
            A.popleft()
        elif command[6] == "L":
            A.pop()
        elif command[0] == "i":
            A.appendleft(int(command[7:]))
        else:
            try:
                A.remove(int(command[7:]))
            except ValueError:
                continue

    print(*A)

