# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_C&lang=jp
sample_input = list(range(3))
sample_input[0] = '''7
insert 5
insert 2
insert 3
insert 1
delete 3
insert 6
delete 5'''
sample_input[1] = '''9
insert 5
insert 2
insert 3
insert 1
delete 3
insert 6
delete 5
deleteFirst
deleteLast'''
sample_input[2] = '''8
insert 1000000000
insert 999999999
deleteLast
insert 1234566890
insert 5
deleteFirst
insert 7
delete 5'''
give_sample_input = None
if give_sample_input is not None:
    sample_input_list = sample_input[give_sample_input].split('\n')
    def input():
        return sample_input_list.pop(0)
        
# main
from collections import deque

num_of_command = int(input())
doubly_list = deque()
for n in range(num_of_command):
    str_command = input()
    if str_command == 'deleteFirst':
        doubly_list.popleft()
        continue
    elif str_command == 'deleteLast':
        doubly_list.pop()
        continue
    command_name = str_command.split()[0]
    command_obj = int(str_command.split()[1])
    if command_name == 'insert':
        doubly_list.appendleft(command_obj)
    elif command_name == 'delete':
        try:
            doubly_list.remove(command_obj)
        except ValueError:
            continue

output = ''
for item in doubly_list:
    output += str(item) + ' '
output = output.rstrip()
print(output) sample_input = list(range(3)) sample_input list(range(3)) list range(3) range 3 sample_input[0] = '''7
insert 5
insert 2
insert 3
insert 1
delete 3
insert 6
delete 5''' sample_input[0] sample_input 0 '''7
insert 5
insert 2
insert 3
insert 1
delete 3
insert 6
delete 5''' sample_input[1] = '''9
insert 5
insert 2
insert 3
insert 1
delete 3
insert 6
delete 5
deleteFirst
deleteLast''' sample_input[1] sample_input 1 '''9
insert 5
insert 2
insert 3
insert 1
delete 3
insert 6
delete 5
deleteFirst
deleteLast''' sample_input[2] = '''8
insert 1000000000
insert 999999999
deleteLast
insert 1234566890
insert 5
deleteFirst
insert 7
delete 5''' sample_input[2] sample_input 2 '''8
insert 1000000000
insert 999999999
deleteLast
insert 1234566890
insert 5
deleteFirst
insert 7
delete 5''' give_sample_input = None give_sample_input None if give_sample_input is not None:
    sample_input_list = sample_input[give_sample_input].split('\n')
    def input():
        return sample_input_list.pop(0)
        
# main give_sample_input is not None give_sample_input None sample_input_list = sample_input[give_sample_input].split('\n') sample_input_list sample_input[give_sample_input].split('\n') [give_sample_input].split [give_sample_input] sample_input give_sample_input split '\n' def input():
        return sample_input_list.pop(0)
        
# main input return sample_input_list.pop(0) sample_input_list.pop(0) sample_input_list.pop sample_input_list pop 0 from collections import deque num_of_command = int(input()) num_of_command int(input()) int input() input doubly_list = deque() doubly_list deque() deque for n in range(num_of_command):
    str_command = input()
    if str_command == 'deleteFirst':
        doubly_list.popleft()
        continue
    elif str_command == 'deleteLast':
        doubly_list.pop()
        continue
    command_name = str_command.split()[0]
    command_obj = int(str_command.split()[1])
    if command_name == 'insert':
        doubly_list.appendleft(command_obj)
    elif command_name == 'delete':
        try:
            doubly_list.remove(command_obj)
        except ValueError:
            continue n range(num_of_command) range num_of_command str_command = input() str_command input() input if str_command == 'deleteFirst':
        doubly_list.popleft()
        continue
    elif str_command == 'deleteLast':
        doubly_list.pop()
        continue
     str_command == 'deleteFirst' str_command 'deleteFirst' doubly_list.popleft() doubly_list.popleft doubly_list popleft continue elif str_command == 'deleteLast':
        doubly_list.pop()
        continue
     str_command == 'deleteLast' str_command 'deleteLast' doubly_list.pop() doubly_list.pop doubly_list pop continue command_name = str_command.split()[0] command_name str_command.split()[0] str_command.split() str_command.split str_command split 0 command_obj = int(str_command.split()[1]) command_obj int(str_command.split()[1]) int str_command.split()[1] str_command.split() str_command.split str_command split 1 if command_name == 'insert':
        doubly_list.appendleft(command_obj)
    elif command_name == 'delete':
        try:
            doubly_list.remove(command_obj)
        except ValueError:
            continue command_name == 'insert' command_name 'insert' doubly_list.appendleft(command_obj) doubly_list.appendleft doubly_list appendleft command_obj elif command_name == 'delete':
        try:
            doubly_list.remove(command_obj)
        except ValueError:
            continue command_name == 'delete' command_name 'delete' try:
            doubly_list.remove(command_obj)
        except ValueError:
            continue except ValueError:
            continue continue doubly_list.remove(command_obj) doubly_list.remove doubly_list remove command_obj output = '' output '' for item in doubly_list:
    output += str(item) + ' ' item doubly_list output += str(item) + ' ' output str(item) + ' ' str(item) str item ' ' output = output.rstrip() output output.rstrip() output.rstrip output rstrip print(output) print output str_command = input() input() str_command sample_input = list(range(3)) list(range(3)) sample_input num_of_command = int(input()) int(input()) num_of_command command_obj = int(str_command.split()[1]) int(str_command.split()[1]) command_obj give_sample_input = None None give_sample_input output += str(item) + ' ' str(item) + ' ' output output = output.rstrip() output.rstrip() output output = '' '' output doubly_list = deque() deque() doubly_list command_name = str_command.split()[0] str_command.split()[0] command_name sample_input_list = sample_input[give_sample_input].split('\n') sample_input[give_sample_input].split('\n') sample_input_list def input():
        return sample_input_list.pop(0)
        
# main def input():
        return sample_input_list.pop(0)
        
# main input
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_C&lang=jp
sample_input = list(range(3))
sample_input[0] = '''7
insert 5
insert 2
insert 3
insert 1
delete 3
insert 6
delete 5'''
sample_input[1] = '''9
insert 5
insert 2
insert 3
insert 1
delete 3
insert 6
delete 5
deleteFirst
deleteLast'''
sample_input[2] = '''8
insert 1000000000
insert 999999999
deleteLast
insert 1234566890
insert 5
deleteFirst
insert 7
delete 5'''
give_sample_input = None
if give_sample_input is not None:
    sample_input_list = sample_input[give_sample_input].split('\n')
    def input():
        return sample_input_list.pop(0)
        
# main
from collections import deque

num_of_command = int(input())
doubly_list = deque()
for n in range(num_of_command):
    str_command = input()
    if str_command == 'deleteFirst':
        doubly_list.popleft()
        continue
    elif str_command == 'deleteLast':
        doubly_list.pop()
        continue
    command_name = str_command.split()[0]
    command_obj = int(str_command.split()[1])
    if command_name == 'insert':
        doubly_list.appendleft(command_obj)
    elif command_name == 'delete':
        try:
            doubly_list.remove(command_obj)
        except ValueError:
            continue

output = ''
for item in doubly_list:
    output += str(item) + ' '
output = output.rstrip()
print(output)