from collections import deque
n = int(input())
dl = deque()
for _ in range(n):
    op = input().split()
    if   op[0] == 'insert'     : dl.appendleft(op[1]) 
    elif op[0] == 'delete'     :
        if op[1] in dl: dl.remove(op[1])
    elif op[0] == 'deleteFirst': dl.popleft() 
    elif op[0] == 'deleteLast' : dl.pop() 
print(*dl) from collections import deque n = int(input()) n int(input()) int input() input dl = deque() dl deque() deque for _ in range(n):
    op = input().split()
    if   op[0] == 'insert'     : dl.appendleft(op[1]) 
    elif op[0] == 'delete'     :
        if op[1] in dl: dl.remove(op[1])
    elif op[0] == 'deleteFirst': dl.popleft() 
    elif op[0] == 'deleteLast' : dl.pop()  _ range(n) range n op = input().split() op input().split() ().split () input split if   op[0] == 'insert'     : dl.appendleft(op[1]) 
    elif op[0] == 'delete'     :
        if op[1] in dl: dl.remove(op[1])
    elif op[0] == 'deleteFirst': dl.popleft() 
    elif op[0] == 'deleteLast' : dl.pop()  op[0] == 'insert' op[0] op 0 'insert' elif op[0] == 'delete'     :
        if op[1] in dl: dl.remove(op[1])
     op[0] == 'delete' op[0] op 0 'delete' if op[1] in dl: dl.remove(op[1])
     op[1] in dl op[1] op 1 dl elif op[0] == 'deleteFirst': dl.popleft() 
     op[0] == 'deleteFirst' op[0] op 0 'deleteFirst' elif op[0] == 'deleteLast' : dl.po op[0] == 'deleteLast' op[0] op 0 'deleteLast' print(*dl) print *dl dl dl = deque() deque() dl n = int(input()) int(input()) n op = input().split() input().split() op
from collections import deque
n = int(input())
dl = deque()
for _ in range(n):
    op = input().split()
    if   op[0] == 'insert'     : dl.appendleft(op[1]) 
    elif op[0] == 'delete'     :
        if op[1] in dl: dl.remove(op[1])
    elif op[0] == 'deleteFirst': dl.popleft() 
    elif op[0] == 'deleteLast' : dl.pop() 
print(*dl)