# -*- coding:utf-8 -*-

from collections import deque

result = deque()

def operation(command):
    if command[0] == "insert":
        result.appendleft(command[1])
    elif command[0] == "delete":
        if command[1] in result:
            result.remove(command[1])
    elif command[0] == "deleteFirst":
        result.popleft()
    elif command[0] == "deleteLast":
        result.pop()

n = int(input())
for i in range(n):
    command = input().split()
    operation(command)
print(*result) from collections import deque result = deque() result deque() deque def operation(command):
    if command[0] == "insert":
        result.appendleft(command[1])
    elif command[0] == "delete":
        if command[1] in result:
            result.remove(command[1])
    elif command[0] == "deleteFirst":
        result.popleft()
    elif command[0] == "deleteLast":
        result.pop() operation if command[0] == "insert":
        result.appendleft(command[1])
    elif command[0] == "delete":
        if command[1] in result:
            result.remove(command[1])
    elif command[0] == "deleteFirst":
        result.popleft()
    elif command[0] == "deleteLast":
        result.pop() command[0] == "insert" command[0] command 0 "insert" result.appendleft(command[1]) result.appendleft result appendleft command[1] command 1 elif command[0] == "delete":
        if command[1] in result:
            result.remove(command[1])
     command[0] == "delete" command[0] command 0 "delete" if command[1] in result:
            result.remove(command[1])
     command[1] in result command[1] command 1 result result.remove(command[1]) result.remove result remove command[1] command 1 elif command[0] == "deleteFirst":
        result.popleft()
     command[0] == "deleteFirst" command[0] command 0 "deleteFirst" result.popleft() result.popleft result popleft elif command[0] == "deleteLast":
        result.pop() command[0] == "deleteLast" command[0] command 0 "deleteLast" result.pop() result.pop result pop command command n = int(input()) n int(input()) int input() input for i in range(n):
    command = input().split()
    operation(command) i range(n) range n command = input().split() command input().split() ().split () input split operation(command) operation command print(*result) print *result result command = input().split() input().split() command n = int(input()) int(input()) n def operation(command):
    if command[0] == "insert":
        result.appendleft(command[1])
    elif command[0] == "delete":
        if command[1] in result:
            result.remove(command[1])
    elif command[0] == "deleteFirst":
        result.popleft()
    elif command[0] == "deleteLast":
        result.pop() def operation(command):
    if command[0] == "insert":
        result.appendleft(command[1])
    elif command[0] == "delete":
        if command[1] in result:
            result.remove(command[1])
    elif command[0] == "deleteFirst":
        result.popleft()
    elif command[0] == "deleteLast":
        result.pop() operation result = deque() deque() result
# -*- coding:utf-8 -*-

from collections import deque

result = deque()

def operation(command):
    if command[0] == "insert":
        result.appendleft(command[1])
    elif command[0] == "delete":
        if command[1] in result:
            result.remove(command[1])
    elif command[0] == "deleteFirst":
        result.popleft()
    elif command[0] == "deleteLast":
        result.pop()

n = int(input())
for i in range(n):
    command = input().split()
    operation(command)
print(*result)