from collections import deque
n=int(input())
dq=deque()

for i in range(n):
    cmd=input().split()
    if cmd[0]=="insert":
        dq.appendleft(cmd[1])
    elif cmd[0]=="deleteFirst":
        dq.popleft()
    elif cmd[0]=="deleteLast":
        dq.pop()
    elif cmd[0]=="delete":
        try:
            dq.remove(cmd[1])
        except:
            pass
print(*dq) from collections import deque n=int(input()) n int(input()) int input() input dq=deque() dq deque() deque for i in range(n):
    cmd=input().split()
    if cmd[0]=="insert":
        dq.appendleft(cmd[1])
    elif cmd[0]=="deleteFirst":
        dq.popleft()
    elif cmd[0]=="deleteLast":
        dq.pop()
    elif cmd[0]=="delete":
        try:
            dq.remove(cmd[1])
        except:
            pass i range(n) range n cmd=input().split() cmd input().split() ().split () input split if cmd[0]=="insert":
        dq.appendleft(cmd[1])
    elif cmd[0]=="deleteFirst":
        dq.popleft()
    elif cmd[0]=="deleteLast":
        dq.pop()
    elif cmd[0]=="delete":
        try:
            dq.remove(cmd[1])
        except:
            pass cmd[0]=="insert" cmd[0] cmd 0 "insert" dq.appendleft(cmd[1]) dq.appendleft dq appendleft cmd[1] cmd 1 elif cmd[0]=="deleteFirst":
        dq.popleft()
     cmd[0]=="deleteFirst" cmd[0] cmd 0 "deleteFirst" dq.popleft() dq.popleft dq popleft elif cmd[0]=="deleteLast":
        dq.pop()
     cmd[0]=="deleteLast" cmd[0] cmd 0 "deleteLast" dq.pop() dq.pop dq pop elif cmd[0]=="delete":
        try:
            dq.remove(cmd[1])
        except:
            pass cmd[0]=="delete" cmd[0] cmd 0 "delete" try:
            dq.remove(cmd[1])
        except:
            pass except:
            pass dq.remove(cmd[1]) dq.remove dq remove cmd[1] cmd 1 print(*dq) print *dq dq dq=deque() deque() dq cmd=input().split() input().split() cmd n=int(input()) int(input()) n
from collections import deque
n=int(input())
dq=deque()

for i in range(n):
    cmd=input().split()
    if cmd[0]=="insert":
        dq.appendleft(cmd[1])
    elif cmd[0]=="deleteFirst":
        dq.popleft()
    elif cmd[0]=="deleteLast":
        dq.pop()
    elif cmd[0]=="delete":
        try:
            dq.remove(cmd[1])
        except:
            pass
print(*dq)