import collections


num_op = int(input())
dllist = collections.deque()

for i in range(0, num_op):
    op = input().split(' ')
    if op[0] == 'insert':
        dllist.appendleft(op[1])
    elif op[0] == 'delete':
        if op[1] in dllist:
            dllist.remove(op[1])
    elif op[0] == 'deleteFirst':
        dllist.popleft()
    elif op[0] == 'deleteLast':
        dllist.pop()

print(' '.join(dllist)) import collections collections num_op = int(input()) num_op int(input()) int input() input dllist = collections.deque() dllist collections.deque() collections.deque collections deque for i in range(0, num_op):
    op = input().split(' ')
    if op[0] == 'insert':
        dllist.appendleft(op[1])
    elif op[0] == 'delete':
        if op[1] in dllist:
            dllist.remove(op[1])
    elif op[0] == 'deleteFirst':
        dllist.popleft()
    elif op[0] == 'deleteLast':
        dllist.pop() i range(0, num_op) range 0 num_op op = input().split(' ') op input().split(' ') ().split () input split ' ' if op[0] == 'insert':
        dllist.appendleft(op[1])
    elif op[0] == 'delete':
        if op[1] in dllist:
            dllist.remove(op[1])
    elif op[0] == 'deleteFirst':
        dllist.popleft()
    elif op[0] == 'deleteLast':
        dllist.pop() op[0] == 'insert' op[0] op 0 'insert' dllist.appendleft(op[1]) dllist.appendleft dllist appendleft op[1] op 1 elif op[0] == 'delete':
        if op[1] in dllist:
            dllist.remove(op[1])
     op[0] == 'delete' op[0] op 0 'delete' if op[1] in dllist:
            dllist.remove(op[1])
     op[1] in dllist op[1] op 1 dllist dllist.remove(op[1]) dllist.remove dllist remove op[1] op 1 elif op[0] == 'deleteFirst':
        dllist.popleft()
     op[0] == 'deleteFirst' op[0] op 0 'deleteFirst' dllist.popleft() dllist.popleft dllist popleft elif op[0] == 'deleteLast':
        dllist.pop() op[0] == 'deleteLast' op[0] op 0 'deleteLast' dllist.pop() dllist.pop dllist pop print(' '.join(dllist)) print ' '.join(dllist) ' '.join ' ' join dllist num_op = int(input()) int(input()) num_op op = input().split(' ') input().split(' ') op dllist = collections.deque() collections.deque() dllist
import collections


num_op = int(input())
dllist = collections.deque()

for i in range(0, num_op):
    op = input().split(' ')
    if op[0] == 'insert':
        dllist.appendleft(op[1])
    elif op[0] == 'delete':
        if op[1] in dllist:
            dllist.remove(op[1])
    elif op[0] == 'deleteFirst':
        dllist.popleft()
    elif op[0] == 'deleteLast':
        dllist.pop()

print(' '.join(dllist))
