# coding: utf-8

import sys
from collections import deque

n = int(input())

task_name = (
    "insert",
    "delete",
    "deleteFirst",
    "deleteLast",
)

a = deque()

for task in map(lambda x: [x] if x in task_name else x.split(), sys.stdin.readlines()):
    #deleteFirst,deleteLast
    if len(task) == 1:
        if task[0] == "deleteFirst":
            a.popleft()
        else:
            a.pop()

    #insert,delete
    else:
        if task[0] == "insert":
            a.appendleft(task[1])
        elif task[1] in a:
            a.remove(task[1])

print(*a) import sys sys from collections import deque n = int(input()) n int(input()) int input() input task_name = (
    "insert",
    "delete",
    "deleteFirst",
    "deleteLast",
) task_name (
    "insert",
    "delete",
    "deleteFirst",
    "deleteLast",
) "insert" "delete" "deleteFirst" "deleteLast" a = deque() a deque() deque for task in map(lambda x: [x] if x in task_name else x.split(), sys.stdin.readlines()):
    #deleteFirst,deleteLast
    if len(task) == 1:
        if task[0] == "deleteFirst":
            a.popleft()
        else:
            a.pop()

    #insert,delete
    else:
        if task[0] == "insert":
            a.appendleft(task[1])
        elif task[1] in a:
            a.remove(task[1]) task map(lambda x: [x] if x in task_name else x.split(), sys.stdin.readlines()) map lambda x: [x] if x in task_name else x.split() [x] if x in task_name else x.split() x in task_name x task_name [x] x x.split() x.split x split x sys.stdin.readlines() sys.stdin.readlines sys.stdin sys stdin readlines if len(task) == 1:
        if task[0] == "deleteFirst":
            a.popleft()
        else:
            a.pop()

    #insert,delete
    else:
        if task[0] == "insert":
            a.appendleft(task[1])
        elif task[1] in a:
            a.remove(task[1]) len(task) == 1 len(task) len task 1 if task[0] == "deleteFirst":
            a.popleft()
        else:
            a.pop()

    #insert,delete
     task[0] == "deleteFirst" task[0] task 0 "deleteFirst" a.popleft() a.popleft a popleft a.pop() a.pop a pop if task[0] == "insert":
            a.appendleft(task[1])
        elif task[1] in a:
            a.remove(task[1]) task[0] == "insert" task[0] task 0 "insert" a.appendleft(task[1]) a.appendleft a appendleft task[1] task 1 elif task[1] in a:
            a.remove(task[1]) task[1] in a task[1] task 1 a a.remove(task[1]) a.remove a remove task[1] task 1 print(*a) print *a a task_name = (
    "insert",
    "delete",
    "deleteFirst",
    "deleteLast",
) (
    "insert",
    "delete",
    "deleteFirst",
    "deleteLast",
) task_name a = deque() deque() a n = int(input()) int(input()) n
# coding: utf-8

import sys
from collections import deque

n = int(input())

task_name = (
    "insert",
    "delete",
    "deleteFirst",
    "deleteLast",
)

a = deque()

for task in map(lambda x: [x] if x in task_name else x.split(), sys.stdin.readlines()):
    #deleteFirst,deleteLast
    if len(task) == 1:
        if task[0] == "deleteFirst":
            a.popleft()
        else:
            a.pop()

    #insert,delete
    else:
        if task[0] == "insert":
            a.appendleft(task[1])
        elif task[1] in a:
            a.remove(task[1])

print(*a)