from _collections import deque

n = int(input())
data_input = []
dlList = deque()
for i in range(n):
    x = input().split()
    if x[0] == 'insert':
        dlList.appendleft(x[1])
    elif x[0] == 'delete':
        if x[1] in dlList:
            dlList.remove(x[1])
        else :
            pass
    elif x[0] == 'deleteFirst':
        dlList.popleft()
    elif x[0] == 'deleteLast':
        dlList.pop()
    else:
        pass

print(' '.join(dlList)) from _collections import deque n = int(input()) n int(input()) int input() input data_input = [] data_input [] dlList = deque() dlList deque() deque for i in range(n):
    x = input().split()
    if x[0] == 'insert':
        dlList.appendleft(x[1])
    elif x[0] == 'delete':
        if x[1] in dlList:
            dlList.remove(x[1])
        else :
            pass
    elif x[0] == 'deleteFirst':
        dlList.popleft()
    elif x[0] == 'deleteLast':
        dlList.pop()
    else:
        pass i range(n) range n x = input().split() x input().split() ().split () input split if x[0] == 'insert':
        dlList.appendleft(x[1])
    elif x[0] == 'delete':
        if x[1] in dlList:
            dlList.remove(x[1])
        else :
            pass
    elif x[0] == 'deleteFirst':
        dlList.popleft()
    elif x[0] == 'deleteLast':
        dlList.pop()
    else:
        pass x[0] == 'insert' x[0] x 0 'insert' dlList.appendleft(x[1]) dlList.appendleft dlList appendleft x[1] x 1 elif x[0] == 'delete':
        if x[1] in dlList:
            dlList.remove(x[1])
        else :
            pass
     x[0] == 'delete' x[0] x 0 'delete' if x[1] in dlList:
            dlList.remove(x[1])
        else :
            pass
     x[1] in dlList x[1] x 1 dlList dlList.remove(x[1]) dlList.remove dlList remove x[1] x 1 elif x[0] == 'deleteFirst':
        dlList.popleft()
     x[0] == 'deleteFirst' x[0] x 0 'deleteFirst' dlList.popleft() dlList.popleft dlList popleft elif x[0] == 'deleteLast':
        dlList.pop()
     x[0] == 'deleteLast' x[0] x 0 'deleteLast' dlList.pop() dlList.pop dlList pop print(' '.join(dlList)) print ' '.join(dlList) ' '.join ' ' join dlList x = input().split() input().split() x n = int(input()) int(input()) n data_input = [] [] data_input dlList = deque() deque() dlList
from _collections import deque

n = int(input())
data_input = []
dlList = deque()
for i in range(n):
    x = input().split()
    if x[0] == 'insert':
        dlList.appendleft(x[1])
    elif x[0] == 'delete':
        if x[1] in dlList:
            dlList.remove(x[1])
        else :
            pass
    elif x[0] == 'deleteFirst':
        dlList.popleft()
    elif x[0] == 'deleteLast':
        dlList.pop()
    else:
        pass

print(' '.join(dlList))