from collections import deque
que = deque([])

n = int(input())

for _ in range(n):
    input_command = input()
    if input_command == "deleteFirst":
        que.popleft()
    elif input_command == "deleteLast":
        que.pop()
    else:
        command, x = input_command.split()
        if command == "insert":
            que.appendleft(x)
        elif command == "delete":
            try:
                que.remove(x)
            except:
                pass
print(" ".join(que)) from collections import deque que = deque([]) que deque([]) deque [] n = int(input()) n int(input()) int input() input for _ in range(n):
    input_command = input()
    if input_command == "deleteFirst":
        que.popleft()
    elif input_command == "deleteLast":
        que.pop()
    else:
        command, x = input_command.split()
        if command == "insert":
            que.appendleft(x)
        elif command == "delete":
            try:
                que.remove(x)
            except:
                pass _ range(n) range n input_command = input() input_command input() input if input_command == "deleteFirst":
        que.popleft()
    elif input_command == "deleteLast":
        que.pop()
    else:
        command, x = input_command.split()
        if command == "insert":
            que.appendleft(x)
        elif command == "delete":
            try:
                que.remove(x)
            except:
                pass input_command == "deleteFirst" input_command "deleteFirst" que.popleft() que.popleft que popleft elif input_command == "deleteLast":
        que.pop()
     input_command == "deleteLast" input_command "deleteLast" que.pop() que.pop que pop command, x = input_command.split() command input_command.split() input_command.split input_command split x if command == "insert":
            que.appendleft(x)
        elif command == "delete":
            try:
                que.remove(x)
            except:
                pass command == "insert" command "insert" que.appendleft(x) que.appendleft que appendleft x elif command == "delete":
            try:
                que.remove(x)
            except:
                pass command == "delete" command "delete" try:
                que.remove(x)
            except:
                pass except:
                pass que.remove(x) que.remove que remove x print(" ".join(que)) print " ".join(que) " ".join " " join que n = int(input()) int(input()) n input_command = input() input() input_command command, x = input_command.split() input_command.split() command que = deque([]) deque([]) que x = input_command.split() input_command.split() x
from collections import deque
que = deque([])

n = int(input())

for _ in range(n):
    input_command = input()
    if input_command == "deleteFirst":
        que.popleft()
    elif input_command == "deleteLast":
        que.pop()
    else:
        command, x = input_command.split()
        if command == "insert":
            que.appendleft(x)
        elif command == "delete":
            try:
                que.remove(x)
            except:
                pass
print(" ".join(que))
