import sys
from collections import deque
input_lines = sys.stdin.readlines()

doublyLinkedList = deque()


for x in input_lines[1:]:
    oneLine = x.split()
    if 'insert' in oneLine[0]:
        doublyLinkedList.appendleft((int)(oneLine[1]))
    elif 'delete' == oneLine[0]:
        remove_value = (int)(oneLine[1])
        if remove_value in doublyLinkedList:
            doublyLinkedList.remove(remove_value)
    elif 'deleteFirst'in oneLine[0]:
        doublyLinkedList.popleft()
    elif 'deleteLast' in oneLine[0]:
        doublyLinkedList.pop()

print(*doublyLinkedList) import sys sys from collections import deque input_lines = sys.stdin.readlines() input_lines sys.stdin.readlines() sys.stdin.readlines sys.stdin sys stdin readlines doublyLinkedList = deque() doublyLinkedList deque() deque for x in input_lines[1:]:
    oneLine = x.split()
    if 'insert' in oneLine[0]:
        doublyLinkedList.appendleft((int)(oneLine[1]))
    elif 'delete' == oneLine[0]:
        remove_value = (int)(oneLine[1])
        if remove_value in doublyLinkedList:
            doublyLinkedList.remove(remove_value)
    elif 'deleteFirst'in oneLine[0]:
        doublyLinkedList.popleft()
    elif 'deleteLast' in oneLine[0]:
        doublyLinkedList.pop() x input_lines[1:] input_lines 1: 1 oneLine = x.split() oneLine x.split() x.split x split if 'insert' in oneLine[0]:
        doublyLinkedList.appendleft((int)(oneLine[1]))
    elif 'delete' == oneLine[0]:
        remove_value = (int)(oneLine[1])
        if remove_value in doublyLinkedList:
            doublyLinkedList.remove(remove_value)
    elif 'deleteFirst'in oneLine[0]:
        doublyLinkedList.popleft()
    elif 'deleteLast' in oneLine[0]:
        doublyLinkedList.pop() 'insert' in oneLine[0] 'insert' oneLine[0] oneLine 0 doublyLinkedList.appendleft((int)(oneLine[1])) doublyLinkedList.appendleft doublyLinkedList appendleft (int)(oneLine[1]) int oneLine[1] oneLine 1 elif 'delete' == oneLine[0]:
        remove_value = (int)(oneLine[1])
        if remove_value in doublyLinkedList:
            doublyLinkedList.remove(remove_value)
     'delete' == oneLine[0] 'delete' oneLine[0] oneLine 0 remove_value = (int)(oneLine[1]) remove_value (int)(oneLine[1]) int oneLine[1] oneLine 1 if remove_value in doublyLinkedList:
            doublyLinkedList.remove(remove_value)
     remove_value in doublyLinkedList remove_value doublyLinkedList doublyLinkedList.remove(remove_value) doublyLinkedList.remove doublyLinkedList remove remove_value elif 'deleteFirst'in oneLine[0]:
        doublyLinkedList.popleft()
     'deleteFirst'in oneLine[0] 'deleteFirst' oneLine[0] oneLine 0 doublyLinkedList.popleft() doublyLinkedList.popleft doublyLinkedList popleft elif 'deleteLast' in oneLine[0]:
        doublyLinkedList.pop() 'deleteLast' in oneLine[0] 'deleteLast' oneLine[0] oneLine 0 doublyLinkedList.pop() doublyLinkedList.pop doublyLinkedList pop print(*doublyLinkedList) print *doublyLinkedList doublyLinkedList doublyLinkedList = deque() deque() doublyLinkedList input_lines = sys.stdin.readlines() sys.stdin.readlines() input_lines oneLine = x.split() x.split() oneLine remove_value = (int)(oneLine[1]) (int)(oneLine[1]) remove_value
import sys
from collections import deque
input_lines = sys.stdin.readlines()

doublyLinkedList = deque()


for x in input_lines[1:]:
    oneLine = x.split()
    if 'insert' in oneLine[0]:
        doublyLinkedList.appendleft((int)(oneLine[1]))
    elif 'delete' == oneLine[0]:
        remove_value = (int)(oneLine[1])
        if remove_value in doublyLinkedList:
            doublyLinkedList.remove(remove_value)
    elif 'deleteFirst'in oneLine[0]:
        doublyLinkedList.popleft()
    elif 'deleteLast' in oneLine[0]:
        doublyLinkedList.pop()

print(*doublyLinkedList)