from collections import deque
n = int(input())
li = deque()
for i in range(n):
    command = input().split()
    if command[0] == 'insert':
        li.appendleft(command[1])
    elif command[0] == 'delete':
        if command[1] in li:
            li.remove(command[1])
    elif command[0] == 'deleteFirst':
        li.popleft()
    else:
        li.pop()
print(*li) from collections import deque n = int(input()) n int(input()) int input() input li = deque() li deque() deque for i in range(n):
    command = input().split()
    if command[0] == 'insert':
        li.appendleft(command[1])
    elif command[0] == 'delete':
        if command[1] in li:
            li.remove(command[1])
    elif command[0] == 'deleteFirst':
        li.popleft()
    else:
        li.pop() i range(n) range n command = input().split() command input().split() ().split () input split if command[0] == 'insert':
        li.appendleft(command[1])
    elif command[0] == 'delete':
        if command[1] in li:
            li.remove(command[1])
    elif command[0] == 'deleteFirst':
        li.popleft()
    else:
        li.pop() command[0] == 'insert' command[0] command 0 'insert' li.appendleft(command[1]) li.appendleft li appendleft command[1] command 1 elif command[0] == 'delete':
        if command[1] in li:
            li.remove(command[1])
     command[0] == 'delete' command[0] command 0 'delete' if command[1] in li:
            li.remove(command[1])
     command[1] in li command[1] command 1 li li.remove(command[1]) li.remove li remove command[1] command 1 elif command[0] == 'deleteFirst':
        li.popleft()
     command[0] == 'deleteFirst' command[0] command 0 'deleteFirst' li.popleft() li.popleft li popleft li.pop() li.pop li pop print(*li) print *li li n = int(input()) int(input()) n li = deque() deque() li command = input().split() input().split() command
from collections import deque
n = int(input())
li = deque()
for i in range(n):
    command = input().split()
    if command[0] == 'insert':
        li.appendleft(command[1])
    elif command[0] == 'delete':
        if command[1] in li:
            li.remove(command[1])
    elif command[0] == 'deleteFirst':
        li.popleft()
    else:
        li.pop()
print(*li)