from collections import deque

if __name__ == "__main__":
    N = int(input())

    num_list = deque([])
    for i in range(N):
        command = input()
        if "insert" in command:
            key = command.split()[1]
            num_list.appendleft(key)
        else:
            if "First" in command:
                num_list.popleft()
            elif "Last" in command:
                num_list.pop()
            else:
                key = command.split()[1]
                if (key in num_list):
                    num_list.remove(key)

    print(" ".join(list(num_list)))
 from collections import deque if __name__ == "__main__":
    N = int(input())

    num_list = deque([])
    for i in range(N):
        command = input()
        if "insert" in command:
            key = command.split()[1]
            num_list.appendleft(key)
        else:
            if "First" in command:
                num_list.popleft()
            elif "Last" in command:
                num_list.pop()
            else:
                key = command.split()[1]
                if (key in num_list):
                    num_list.remove(key)

    print(" ".join(list(num_list))) __name__ == "__main__" __name__ "__main__" N = int(input()) N int(input()) int input() input num_list = deque([]) num_list deque([]) deque [] for i in range(N):
        command = input()
        if "insert" in command:
            key = command.split()[1]
            num_list.appendleft(key)
        else:
            if "First" in command:
                num_list.popleft()
            elif "Last" in command:
                num_list.pop()
            else:
                key = command.split()[1]
                if (key in num_list):
                    num_list.remove(key)

     i range(N) range N command = input() command input() input if "insert" in command:
            key = command.split()[1]
            num_list.appendleft(key)
        else:
            if "First" in command:
                num_list.popleft()
            elif "Last" in command:
                num_list.pop()
            else:
                key = command.split()[1]
                if (key in num_list):
                    num_list.remove(key)

     "insert" in command "insert" command key = command.split()[1] key command.split()[1] command.split() command.split command split 1 num_list.appendleft(key) num_list.appendleft num_list appendleft key if "First" in command:
                num_list.popleft()
            elif "Last" in command:
                num_list.pop()
            else:
                key = command.split()[1]
                if (key in num_list):
                    num_list.remove(key)

     "First" in command "First" command num_list.popleft() num_list.popleft num_list popleft elif "Last" in command:
                num_list.pop()
             "Last" in command "Last" command num_list.pop() num_list.pop num_list pop key = command.split()[1] key command.split()[1] command.split() command.split command split 1 if (key in num_list):
                    num_list.remove(key)

     key in num_list key num_list num_list.remove(key) num_list.remove num_list remove key print(" ".join(list(num_list))) print " ".join(list(num_list)) " ".join " " join list(num_list) list num_list command = input() input() command key = command.split()[1] command.split()[1] key key = command.split()[1] command.split()[1] key num_list = deque([]) deque([]) num_list N = int(input()) int(input()) N
from collections import deque

if __name__ == "__main__":
    N = int(input())

    num_list = deque([])
    for i in range(N):
        command = input()
        if "insert" in command:
            key = command.split()[1]
            num_list.appendleft(key)
        else:
            if "First" in command:
                num_list.popleft()
            elif "Last" in command:
                num_list.pop()
            else:
                key = command.split()[1]
                if (key in num_list):
                    num_list.remove(key)

    print(" ".join(list(num_list)))

