# collections.deque is implemented using doubly linked list at C level..
from collections import deque

linkedlist = deque()

for _ in range(int(input())):
    input_command = input()
    if input_command == 'deleteFirst':
        linkedlist.popleft()

    elif input_command == 'deleteLast':
        linkedlist.pop()
    
    else:
        com, num = input_command.split()
        if com == 'insert':
            linkedlist.appendleft(num)

        elif com == 'delete':
            try:
                linkedlist.remove(num)
            except:
                pass
            

print(' '.join(linkedlist)) from collections import deque linkedlist = deque() linkedlist deque() deque for _ in range(int(input())):
    input_command = input()
    if input_command == 'deleteFirst':
        linkedlist.popleft()

    elif input_command == 'deleteLast':
        linkedlist.pop()
    
    else:
        com, num = input_command.split()
        if com == 'insert':
            linkedlist.appendleft(num)

        elif com == 'delete':
            try:
                linkedlist.remove(num)
            except:
                pass
             _ range(int(input())) range int(input()) int input() input input_command = input() input_command input() input if input_command == 'deleteFirst':
        linkedlist.popleft()

    elif input_command == 'deleteLast':
        linkedlist.pop()
    
    else:
        com, num = input_command.split()
        if com == 'insert':
            linkedlist.appendleft(num)

        elif com == 'delete':
            try:
                linkedlist.remove(num)
            except:
                pass
             input_command == 'deleteFirst' input_command 'deleteFirst' linkedlist.popleft() linkedlist.popleft linkedlist popleft elif input_command == 'deleteLast':
        linkedlist.pop()
    
     input_command == 'deleteLast' input_command 'deleteLast' linkedlist.pop() linkedlist.pop linkedlist pop com, num = input_command.split() com input_command.split() input_command.split input_command split num if com == 'insert':
            linkedlist.appendleft(num)

        elif com == 'delete':
            try:
                linkedlist.remove(num)
            except:
                pass
             com == 'insert' com 'insert' linkedlist.appendleft(num) linkedlist.appendleft linkedlist appendleft num elif com == 'delete':
            try:
                linkedlist.remove(num)
            except:
                pass
             com == 'delete' com 'delete' try:
                linkedlist.remove(num)
            except:
                pass
             except:
                pass
             linkedlist.remove(num) linkedlist.remove linkedlist remove num print(' '.join(linkedlist)) print ' '.join(linkedlist) ' '.join ' ' join linkedlist linkedlist = deque() deque() linkedlist num = input_command.split() input_command.split() num input_command = input() input() input_command com, num = input_command.split() input_command.split() com
# collections.deque is implemented using doubly linked list at C level..
from collections import deque

linkedlist = deque()

for _ in range(int(input())):
    input_command = input()
    if input_command == 'deleteFirst':
        linkedlist.popleft()

    elif input_command == 'deleteLast':
        linkedlist.pop()
    
    else:
        com, num = input_command.split()
        if com == 'insert':
            linkedlist.appendleft(num)

        elif com == 'delete':
            try:
                linkedlist.remove(num)
            except:
                pass
            

print(' '.join(linkedlist))
