from collections import deque

LIST = deque()

num_command = int(input())

for loop in range(num_command):
    input_command = input()
    if input_command == "deleteFirst":
        LIST.popleft()
    elif input_command == "deleteLast":
        LIST.pop()
    else:
        com,num = input_command.split()
        if com == "insert":
            LIST.appendleft(num)
        elif com == "delete":
            try:
                LIST.remove(num)
            except:
                pass
print(" ".join(LIST)) from collections import deque LIST = deque() LIST deque() deque num_command = int(input()) num_command int(input()) int input() input for loop in range(num_command):
    input_command = input()
    if input_command == "deleteFirst":
        LIST.popleft()
    elif input_command == "deleteLast":
        LIST.pop()
    else:
        com,num = input_command.split()
        if com == "insert":
            LIST.appendleft(num)
        elif com == "delete":
            try:
                LIST.remove(num)
            except:
                pass loop range(num_command) range num_command input_command = input() input_command input() input if input_command == "deleteFirst":
        LIST.popleft()
    elif input_command == "deleteLast":
        LIST.pop()
    else:
        com,num = input_command.split()
        if com == "insert":
            LIST.appendleft(num)
        elif com == "delete":
            try:
                LIST.remove(num)
            except:
                pass input_command == "deleteFirst" input_command "deleteFirst" LIST.popleft() LIST.popleft LIST popleft elif input_command == "deleteLast":
        LIST.pop()
     input_command == "deleteLast" input_command "deleteLast" LIST.pop() LIST.pop LIST pop com,num = input_command.split() com input_command.split() input_command.split input_command split num if com == "insert":
            LIST.appendleft(num)
        elif com == "delete":
            try:
                LIST.remove(num)
            except:
                pass com == "insert" com "insert" LIST.appendleft(num) LIST.appendleft LIST appendleft num elif com == "delete":
            try:
                LIST.remove(num)
            except:
                pass com == "delete" com "delete" try:
                LIST.remove(num)
            except:
                pass except:
                pass LIST.remove(num) LIST.remove LIST remove num print(" ".join(LIST)) print " ".join(LIST) " ".join " " join LIST com,num = input_command.split() input_command.split() com num_command = int(input()) int(input()) num_command num = input_command.split() input_command.split() num LIST = deque() deque() LIST input_command = input() input() input_command
from collections import deque

LIST = deque()

num_command = int(input())

for loop in range(num_command):
    input_command = input()
    if input_command == "deleteFirst":
        LIST.popleft()
    elif input_command == "deleteLast":
        LIST.pop()
    else:
        com,num = input_command.split()
        if com == "insert":
            LIST.appendleft(num)
        elif com == "delete":
            try:
                LIST.remove(num)
            except:
                pass
print(" ".join(LIST))
