### BUGGY CODE ###

# -*- coding: utf-8 -*-
    
class Node(object):
    """Node class
    """

    def __init__(self, key=None, previous_node=None, next_node=None):
        """Constructor
        """
        self.key = key
        ''' key '''

        self.previous_node = previous_node
        ''' previous node '''

        self.next_node = next_node
        ''' next node '''

    def copy_from(self, node):
        self.key = node.key
        self.previous_node = node.previous_node
        self.next_node = node.next_node

    def print_on(self, is_performance=False):
        if is_performance:
            print self.key, 
        else:
            print self.previous_node, str(self.key) + " at " + str(self), self.next_node


class DoublyLinkedList(object):
    """Doubly Linked List Class
    """

    def __init__(self, sentinel_key='SENTINEL'):
        """Constructor(make sentinel node)
        """
        self.sentinel_node = Node(key=sentinel_key)
        self.sentinel_node.next_node = self.sentinel_node
        self.sentinel_node.previous_node = self.sentinel_node

    def insert_node(self, key):
        """insert node which has specified key at first position"""
        
        # set new node
        new_node = Node(key=key, previous_node=self.sentinel_node, next_node=self.sentinel_node.next_node) 
        # re-set first_node
        self.sentinel_node.next_node.previous_node = new_node
        # re-set sentinel node
        self.sentinel_node.next_node = new_node

            

    def delete(self, key=None):
        """ delete node which has a key 'key' """
        target_node = self.sentinel_node.next_node
        while target_node is not self.sentinel_node:
            if target_node.key == key:
                target_node.previous_node.next_node = target_node.next_node
                target_node.next_node.previous_node = target_node.previous_node
                break
            else:
                target_node = target_node.next_node
    
    def delete_first(self):
        """ delete first node """
        # delete first node
        self.sentinel_node.next_node = self.sentinel_node.next_node.next_node
        self.sentinel_node.next_node.previous_node = self.sentinel_node

    def delete_last(self):
        """delete last node """
        self.sentinel_node.previous_node = self.sentinel_node.previous_node.previous_node
        self.sentinel_node.previous_node.next_node = self.sentinel_node

    def print_on(self, is_performance=False):
        target_node = self.sentinel_node
        if not is_performance:
            target_node.print_on(is_performance)
        while target_node.next_node is not self.sentinel_node:
            target_node = target_node.next_node
            target_node.print_on(is_performance)
            

def main():
    doubly_linked_list = DoublyLinkedList()

    input_length = int(raw_input())
    counter = 0
    while counter < input_length:
        counter += 1
        input_line = raw_input().strip()
        # print input_line
        if input_line == 'deleteFirst':
            doubly_linked_list.delete_first()
            continue
        elif input_line == 'deleteLast':
            doubly_linked_list.delete_last()
            continue

        input_command = input_line.split(' ')[0].strip()
        input_key = input_line.split(' ')[1].strip()
        if input_command == 'insert':
            doubly_linked_list.insert_node(input_key)
        elif input_command == 'delete':
            pass
            doubly_linked_list.delete(input_key)
        else:
            "baka"
    doubly_linked_list.print_on(is_performance=True)

if __name__ == '__main__':
    main()

### FIXED CODE ###

# tameshi 
n = input()
lis = []
ans = 0
for i in xrange(n):
    com = raw_input()
    if   com[0] == 'i':
        lis.append(com[7:])
    elif com[6] == ' ':
        try:
            lis.pop(~lis[::-1].index(com[7:]))
        except:
            pass
    elif com[6] == 'F':
        lis.pop()
    else:ans += 1
  
print ' '.join( map(str, reversed(lis[ans:])) )