#! python3
# doubly_linked_list.py

from collections import deque

keys = deque([])

n = int(input())

for i in range(n):
    command = input()
    if command == 'deleteFirst':
        keys.popleft()
    elif command == 'deleteLast':
        keys.pop()
    else:
        command, x = command.split(' ')
        if command == 'insert':
            keys.appendleft(int(x))
        elif command == 'delete':
            if int(x) in keys:
                keys.remove(int(x))

print(' '.join([str(k) for k in keys])) from collections import deque keys = deque([]) keys deque([]) deque [] n = int(input()) n int(input()) int input() input for i in range(n):
    command = input()
    if command == 'deleteFirst':
        keys.popleft()
    elif command == 'deleteLast':
        keys.pop()
    else:
        command, x = command.split(' ')
        if command == 'insert':
            keys.appendleft(int(x))
        elif command == 'delete':
            if int(x) in keys:
                keys.remove(int(x)) i range(n) range n command = input() command input() input if command == 'deleteFirst':
        keys.popleft()
    elif command == 'deleteLast':
        keys.pop()
    else:
        command, x = command.split(' ')
        if command == 'insert':
            keys.appendleft(int(x))
        elif command == 'delete':
            if int(x) in keys:
                keys.remove(int(x)) command == 'deleteFirst' command 'deleteFirst' keys.popleft() keys.popleft keys popleft elif command == 'deleteLast':
        keys.pop()
     command == 'deleteLast' command 'deleteLast' keys.pop() keys.pop keys pop command, x = command.split(' ') command command.split(' ') command.split command split ' ' x if command == 'insert':
            keys.appendleft(int(x))
        elif command == 'delete':
            if int(x) in keys:
                keys.remove(int(x)) command == 'insert' command 'insert' keys.appendleft(int(x)) keys.appendleft keys appendleft int(x) int x elif command == 'delete':
            if int(x) in keys:
                keys.remove(int(x)) command == 'delete' command 'delete' if int(x) in keys:
                keys.remove(int(x)) int(x) in keys int(x) int x keys keys.remove(int(x)) keys.remove keys remove int(x) int x str(k) for k in keys for k in keys k keys for k in keys str(k) str k print(' '.join([str(k) for k in keys])) print ' '.join([str(k) for k in keys]) ' '.join ' ' join [str(k) for k in keys] keys = deque([]) deque([]) keys n = int(input()) int(input()) n command = input() input() command x = command.split(' ') command.split(' ') x command, x = command.split(' ') command.split(' ') command
#! python3
# doubly_linked_list.py

from collections import deque

keys = deque([])

n = int(input())

for i in range(n):
    command = input()
    if command == 'deleteFirst':
        keys.popleft()
    elif command == 'deleteLast':
        keys.pop()
    else:
        command, x = command.split(' ')
        if command == 'insert':
            keys.appendleft(int(x))
        elif command == 'delete':
            if int(x) in keys:
                keys.remove(int(x))

print(' '.join([str(k) for k in keys]))
