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

