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