from collections import deque

n = int(input())
dq = deque([])
for _ in range(n):
    L = input().split()
    if L[0] == 'insert':
        dq.appendleft(L[1])
    elif L[0] == 'delete':
        if L[1] in dq: dq.remove(L[1])
    elif L[0] == 'deleteFirst':
        dq.popleft()
    else:
        dq.pop()

print(' '.join(dq)) from collections import deque n = int(input()) n int(input()) int input() input dq = deque([]) dq deque([]) deque [] for _ in range(n):
    L = input().split()
    if L[0] == 'insert':
        dq.appendleft(L[1])
    elif L[0] == 'delete':
        if L[1] in dq: dq.remove(L[1])
    elif L[0] == 'deleteFirst':
        dq.popleft()
    else:
        dq.pop() _ range(n) range n L = input().split() L input().split() ().split () input split if L[0] == 'insert':
        dq.appendleft(L[1])
    elif L[0] == 'delete':
        if L[1] in dq: dq.remove(L[1])
    elif L[0] == 'deleteFirst':
        dq.popleft()
    else:
        dq.pop() L[0] == 'insert' L[0] L 0 'insert' dq.appendleft(L[1]) dq.appendleft dq appendleft L[1] L 1 elif L[0] == 'delete':
        if L[1] in dq: dq.remove(L[1])
     L[0] == 'delete' L[0] L 0 'delete' if L[1] in dq: dq.remove(L[1])
     L[1] in dq L[1] L 1 dq elif L[0] == 'deleteFirst':
        dq.popleft()
     L[0] == 'deleteFirst' L[0] L 0 'deleteFirst' dq.popleft() dq.popleft dq popleft dq.pop() dq.pop dq pop print(' '.join(dq)) print ' '.join(dq) ' '.join ' ' join dq dq = deque([]) deque([]) dq n = int(input()) int(input()) n L = input().split() input().split() L
from collections import deque

n = int(input())
dq = deque([])
for _ in range(n):
    L = input().split()
    if L[0] == 'insert':
        dq.appendleft(L[1])
    elif L[0] == 'delete':
        if L[1] in dq: dq.remove(L[1])
    elif L[0] == 'deleteFirst':
        dq.popleft()
    else:
        dq.pop()

print(' '.join(dq))
