from collections import deque

dq = deque()

n = int(input())

for _ in range(n):
    command = input()
    if command[:6] == 'insert':
        dq.appendleft(command[7:])
    elif command[:10] == 'deleteLast':
        dq.pop()
    elif command[:11] == 'deleteFirst':
        dq.popleft()
    elif command[:6] == 'delete':
        if (command[7:]) in dq:
            dq.remove(command[7:])
print(" ".join(dq))

 from collections import deque dq = deque() dq deque() deque n = int(input()) n int(input()) int input() input for _ in range(n):
    command = input()
    if command[:6] == 'insert':
        dq.appendleft(command[7:])
    elif command[:10] == 'deleteLast':
        dq.pop()
    elif command[:11] == 'deleteFirst':
        dq.popleft()
    elif command[:6] == 'delete':
        if (command[7:]) in dq:
            dq.remove(command[7:]) _ range(n) range n command = input() command input() input if command[:6] == 'insert':
        dq.appendleft(command[7:])
    elif command[:10] == 'deleteLast':
        dq.pop()
    elif command[:11] == 'deleteFirst':
        dq.popleft()
    elif command[:6] == 'delete':
        if (command[7:]) in dq:
            dq.remove(command[7:]) command[:6] == 'insert' command[:6] command :6 6 'insert' dq.appendleft(command[7:]) dq.appendleft dq appendleft command[7:] command 7: 7 elif command[:10] == 'deleteLast':
        dq.pop()
     command[:10] == 'deleteLast' command[:10] command :10 10 'deleteLast' dq.pop() dq.pop dq pop elif command[:11] == 'deleteFirst':
        dq.popleft()
     command[:11] == 'deleteFirst' command[:11] command :11 11 'deleteFirst' dq.popleft() dq.popleft dq popleft elif command[:6] == 'delete':
        if (command[7:]) in dq:
            dq.remove(command[7:]) command[:6] == 'delete' command[:6] command :6 6 'delete' if (command[7:]) in dq:
            dq.remove(command[7:]) (command[7:]) in dq command[7:] command 7: 7 dq dq.remove(command[7:]) dq.remove dq remove command[7:] command 7: 7 print(" ".join(dq)) print " ".join(dq) " ".join " " join dq n = int(input()) int(input()) n command = input() input() command dq = deque() deque() dq
from collections import deque

dq = deque()

n = int(input())

for _ in range(n):
    command = input()
    if command[:6] == 'insert':
        dq.appendleft(command[7:])
    elif command[:10] == 'deleteLast':
        dq.pop()
    elif command[:11] == 'deleteFirst':
        dq.popleft()
    elif command[:6] == 'delete':
        if (command[7:]) in dq:
            dq.remove(command[7:])
print(" ".join(dq))


