# 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
class Node:
    
    def __init__(self, value, prev=None, next=None):
        self.value = value
        self.prev = prev
        self.next = next

class DoublyLinkedList:
    
    def __init__(self):
        self.be_empty()
    
    def be_empty(self):
        self.first = None
        self.last = None
        
    def is_empty(self):
        if self.first is None:
            assert self.last is None
            return True
        else: 
            return False
    
    def insert_node(self, node):
        if self.is_empty():
            self.first = node
            self.last = node
        else:
            self.first.prev = node
            node.next = self.first
            node.prev = None
            self.first = node
        
    def insert(self, x):
        self.insert_node(Node(x))
    
    def delete(self, x):
        '''Note : if x is not found, this does nothing'''
        if self.is_empty():
            return
        else:
            item = self.first
            while item is not None:
                if item.value == x:
                    break
                else:
                    item = item.next
            if item is self.last:
                self.delete_last()
            elif item is self.first:
                self.delete_first()
            else:
                prev = item.prev
                next = item.next
                prev.next = next
                next.prev = prev
                
    
    def delete_first(self):
        if self.first is self.last:
            self.be_empty()
        else:
            second = self.first.next
            second.prev = None
            self.first = second
    
    def delete_last(self):
        if self.first is self.last:
            self.be_empty()
        else:
            second = self.last.prev
            second.next = None
            self.last = second

    def to_str(self):
        output = ''
        if self.is_empty():
            return output
        else:
            item = self.first
            while item is not None:
                output += str(item.value) + ' '
                item = item.next
            output = output.rstrip()
            return output


num_of_command = int(input())
doublely_list = DoublyLinkedList()
for n in range(num_of_command):
    str_command = input()
    if str_command == 'deleteFirst':
        doublely_list.delete_first()
        continue
    elif str_command == 'deleteLast':
        doublely_list.delete_last()
        continue
    command_name = str_command.split()[0]
    command_obj = int(str_command.split()[1])
    if command_name == 'insert':
        doublely_list.insert(command_obj)
    elif command_name == 'delete':
        doublely_list.delete(command_obj)

print(doublely_list.to_str())

### FIXED CODE ###

# 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)